|
22 | 22 |
|
23 | 23 | $crud = Crud::addTo($app, ['ipp' => 10]); |
24 | 24 |
|
25 | | -// callback for model action add form. |
| 25 | +// callback for model action add form |
26 | 26 | $crud->onFormAdd(static function (Form $form, ModalExecutor $ex) use ($model) { |
27 | 27 | $form->js(true, $form->getControl($model->fieldName()->name)->jsInput()->val('Entering value via javascript')); |
28 | 28 | }); |
29 | 29 |
|
30 | | -// callback for model action edit form. |
| 30 | +// callback for model action edit form |
31 | 31 | $crud->onFormEdit(static function (Form $form) use ($model) { |
32 | 32 | $form->js(true, $form->getControl($model->fieldName()->name)->jsInput()->attr('readonly', true)); |
33 | 33 | }); |
|
51 | 51 | 'menu' => ['class' => ['green inverted']], |
52 | 52 | 'table' => ['class' => ['red inverted']], |
53 | 53 | ]); |
54 | | -// Condition on the model can be applied on a model |
| 54 | +// condition on the model can be applied on a model |
55 | 55 | $model = new Country($app->db); |
56 | 56 | $model->addCondition($model->fieldName()->numcode, '<', 200); |
57 | 57 | $model->onHook(Model::HOOK_VALIDATE, static function (Country $model, ?string $intent) { |
|
64 | 64 | }); |
65 | 65 | $crud->setModel($model); |
66 | 66 |
|
67 | | -// Because Crud inherits Grid, you can also define custom actions |
| 67 | +// because Crud inherits Grid, you can also define custom actions |
68 | 68 | $crud->addModalAction(['icon' => 'cogs'], 'Details', static function (View $p, $id) use ($crud) { |
69 | 69 | $model = Country::assertInstanceOf($crud->model); |
70 | 70 | Message::addTo($p, ['Details for: ' . $model->load($id)->name . ' (id: ' . $id . ')']); |
@@ -102,6 +102,6 @@ public function addFormTo(View $view): Form |
102 | 102 |
|
103 | 103 | $crud->menu->addItem(['Rescan', 'icon' => 'recycle']); |
104 | 104 |
|
105 | | -// Condition on the model can be applied after setting the model |
| 105 | +// condition on the model can be applied after setting the model |
106 | 106 | $crud->setModel($file); |
107 | 107 | $file->addCondition($file->fieldName()->parent_folder_id, null); |
0 commit comments