protected function form(Model $model)
    {
        $this->breadcrumb->onItem($model);
        return app('antares.form')->of('awesone-module-form', function(FormGrid $form) use($model) {

                    $form->name('My Awesome Module Form');
                    $form->resourced('antares::sample_module/index', $model);
                    $form->fieldset(function (Fieldset $fieldset) use($model) {

                        $fieldset->legend('Fieldset');
                        if (!auth()->user()->hasRoles('member')) {
                            $fieldset->control('select', 'user')
                                    ->label(trans('antares/sample_module::form.user_select'))
                                    ->options(function() {
                                        return User::members()
                                                ->select([DB::raw('concat(firstname," ",lastname) as name'), 'id'])
                                                ->orderBy('firstname', 'asc')
                                                ->orderBy('lastname', 'desc')
                                                ->get()
                                                ->map(function($option) {
                                                    return ['id' => $option->id, 'title' => '#' . $option->id . ' ' . $option->name];
                                                })->pluck('title', 'id');
                                    })
                                    ->attributes(['data-selectar--search' => true, 'data-placeholder' => 'testowanie'])
                                    ->wrapper(['class' => 'w300'])
                                    ->value($model->user_id);
                        }


                        $fieldset->control('input:text', 'name')
                                ->label(trans('antares/sample_module::form.name'))
                                ->wrapper(['class' => 'w300']);


                        $fieldset->control('select', 'field_1')
                                ->label(trans('antares/sample_module::form.field_1'))
                                ->options(self::getOptions())
                                ->wrapper(['class' => 'w200']);

                        $fieldset->control('input:checkbox', 'field_2')
                                ->label(trans('antares/sample_module::form.field_2'))
                                ->value(1)
                                ->checked($model->exists ? array_get($model->value, 'field_2', false) : false);

                        $fieldset->control('button', 'cancel')
                                ->field(function() {
                                    return app('html')->link(handles("antares::sample_module/index"), trans('antares/foundation::label.cancel'), ['class' => 'btn btn--md btn--default mdl-button mdl-js-button']);
                                });

                        $fieldset->control('button', 'button')
                                ->attributes(['type' => 'submit', 'class' => 'btn btn-primary'])
                                ->value(trans('antares/foundation::label.save_changes'));
                    });
                    $form->ajaxable()->rules(['name' => 'required']);
                });
    }
protected function form(Model $model)
    {
        $this->breadcrumb->onItem($model);
        return app('antares.form')->of('awesone-module-form', function(FormGrid $form) use($model) {

                    $form->name('My Awesome Module Form');
                    $form->resourced('antares::sample_module/index', $model);
                    $form->fieldset(function (Fieldset $fieldset) use($model) {

                        $fieldset->legend('Fieldset');
                        if (!auth()->user()->hasRoles('member')) {
                            $fieldset->control('select', 'user')
                                    ->label(trans('antares/sample_module::form.user_select'))
                                    ->options(function() {
                                        return User::members()
                                                ->select([DB::raw('concat(firstname," ",lastname) as name'), 'id'])
                                                ->orderBy('firstname', 'asc')
                                                ->orderBy('lastname', 'desc')
                                                ->get()
                                                ->map(function($option) {
                                                    return ['id' => $option->id, 'title' => '#' . $option->id . ' ' . $option->name];
                                                })->pluck('title', 'id');
                                    })
                                    ->attributes(['data-selectar--search' => true, 'data-placeholder' => 'testowanie'])
                                    ->wrapper(['class' => 'w300'])
                                    ->value($model->user_id);
                        }


                        $fieldset->control('input:text', 'name')
                                ->label(trans('antares/sample_module::form.name'))
                                ->wrapper(['class' => 'w300']);


                        $fieldset->control('select', 'field_1')
                                ->label(trans('antares/sample_module::form.field_1'))
                                ->options(self::getOptions())
                                ->wrapper(['class' => 'w200']);

                        $fieldset->control('input:checkbox', 'field_2')
                                ->label(trans('antares/sample_module::form.field_2'))
                                ->value(1)
                                ->checked($model->exists ? array_get($model->value, 'field_2', false) : false);

                        $fieldset->control('button', 'cancel')
                                ->field(function() {
                                    return app('html')->link(handles("antares::sample_module/index"), trans('antares/foundation::label.cancel'), ['class' => 'btn btn--md btn--default mdl-button mdl-js-button']);
                                });

                        $fieldset->control('button', 'button')
                                ->attributes(['type' => 'submit', 'class' => 'btn btn-primary'])
                                ->value(trans('antares/foundation::label.save_changes'));
                    });
                    $form->ajaxable()->rules(['name' => 'required']);
                });
    }
protected function form ( Model $ model ) { $ this -> breadcrumb -> onItem ( $ model ) ; return app ( 'antares.form' ) -> of ( 'awesone-module-form' , function ( FormGrid $ form ) use ( $ model ) { $ form -> name ( 'My Awesome Module Form' ) ; $ form -> resourced ( 'antares::sample_module/index' , $ model ) ; $ form -> fieldset ( function ( Fieldset $ fieldset ) use ( $ model ) { $ fieldset -> legend ( 'Fieldset' ) ; if ( ! auth ( ) -> user ( ) -> hasRoles ( 'member' ) ) { $ fieldset -> control ( 'select' , 'user' ) -> label ( trans ( 'antares/sample_module::form.user_select' ) ) -> options ( function ( ) { return User :: members ( ) -> select ( [ DB :: raw ( 'concat(firstname," ",lastname) as name' ) , 'id' ] ) -> orderBy ( 'firstname' , 'asc' ) -> orderBy ( 'lastname' , 'desc' ) -> get ( ) -> map ( function ( $ option ) { return [ 'id' => $ option -> id , 'title' => '#' . $ option -> id . ' ' . $ option -> name ] ; } ) -> pluck ( 'title' , 'id' ) ; } ) -> attributes ( [ 'data-selectar--search' => true , 'data-placeholder' => 'testowanie' ] ) -> wrapper ( [ 'class' => 'w300' ] ) -> value ( $ model -> user_id ) ; } $ fieldset -> control ( 'input:text' , 'name' ) -> label ( trans ( 'antares/sample_module::form.name' ) ) -> wrapper ( [ 'class' => 'w300' ] ) ; $ fieldset -> control ( 'select' , 'field_1' ) -> label ( trans ( 'antares/sample_module::form.field_1' ) ) -> options ( self :: getOptions ( ) ) -> wrapper ( [ 'class' => 'w200' ] ) ; $ fieldset -> control ( 'input:checkbox' , 'field_2' ) -> label ( trans ( 'antares/sample_module::form.field_2' ) ) -> value ( 1 ) -> checked ( $ model -> exists ? array_get ( $ model -> value , 'field_2' , false ) : false ) ; $ fieldset -> control ( 'button' , 'cancel' ) -> field ( function ( ) { return app ( 'html' ) -> link ( handles ( "antares::sample_module/index" ) , trans ( 'antares/foundation::label.cancel' ) , [ 'class' => 'btn btn--md btn--default mdl-button mdl-js-button' ] ) ; } ) ; $ fieldset -> control ( 'button' , 'button' ) -> attributes ( [ 'type' => 'submit' , 'class' => 'btn btn-primary' ] ) -> value ( trans ( 'antares/foundation::label.save_changes' ) ) ; } ) ; $ form -> ajaxable ( ) -> rules ( [ 'name' => 'required' ] ) ; } ) ; }
Generowanie nowego obiektu formularza

@param Model $model
@return \Antares\Html\Form\FormBuilder
Generowanie nowego obiektu formularza