Ejemplo n.º 1
0
 public function createAction()
 {
     $adminModel = $this->dispatcher->getParam('adminModel');
     $class = array_search($adminModel, Admin::modelAliases());
     $model = Admin::model($class);
     $create = $model->create();
     if ($this->request->isPost()) {
         if ($create->validate($model)) {
             $create->save($model);
             return $this->response->redirect($model->displayUrl());
         }
     }
     $content = $this->render($model->title(), $create);
     return $this->response->setContent($content);
 }
Ejemplo n.º 2
0
 public function model()
 {
     return Admin::model($this->class);
 }
Ejemplo n.º 3
0
<?php

use Argentum88\Phad\Admin;
use Argentum88\Phad\Columns\String;
use Argentum88\Phad\ColumnFilters\Text as TextFilter;
use Argentum88\Phad\DisplayDatatablesAsync;
use Argentum88\Phad\FormDefault;
use Argentum88\Phad\FormItems\Text;
use Phalcon\DI;
use Phalcon\Validation\Validator\Email;
use Phalcon\Validation\Validator\PresenceOf;
Admin::menu('App\\User');
Admin::model('App\\User')->title('Users')->display(function () {
    $display = new DisplayDatatablesAsync();
    $display->columnFilters([(new TextFilter())->placeholder('Name')]);
    $display->columns([(new String('name'))->label('Name'), (new String('email'))->label('Email')]);
    return $display;
})->createAndEdit(function () {
    $form = new FormDefault();
    $form->items([(new Text('name', 'Name'))->validationRules([new PresenceOf(['message' => 'The name is required'])]), (new Text('email', 'Email'))->validationRules([new PresenceOf(['message' => 'The email is required']), new Email(['message' => 'The e-mail is not valid'])])]);
    return $form;
});
Ejemplo n.º 4
0
 /**
  * Get related model configuration
  * @return ModelConfiguration
  */
 protected function model()
 {
     return Admin::model(get_class($this->instance));
 }
Ejemplo n.º 5
0
 /**
  * Get related model configuration
  * @return ModelConfiguration
  */
 protected function getModelItem()
 {
     return Admin::model($this->modelClass);
 }
Ejemplo n.º 6
0
 /**
  * Get filter url
  * @return string
  */
 public function getUrl()
 {
     $value = $this->getValue($this->instance, $this->field());
     return Admin::model($this->model)->displayUrl([$this->name() => $value]);
 }