Пример #1
0
 public function createFields()
 {
     $parentFields = parent::createFields();
     //         $parentFields->setSwitchable(true);
     $mainFields = new FieldList('main', trans('cmsable::forms.page-form.main'));
     $mainFields->setClassName('CmsMainFields');
     $mainFields->setSwitchable(TRUE);
     $mainFields->push(TextField::create('title')->setTitle(trans('cmsable::models.page.fields.title')));
     $mainFields->push(TextField::create('menu_title')->setTitle(trans('cmsable::models.page.fields.menu_title')));
     $mainFields->push(UrlSegmentField::create('url_segment')->setTitle(trans('cmsable::models.page.fields.url_segment')));
     $mainFields->push(TextField::create('content')->setTitle(trans('cmsable::models.page.fields.content'))->setMultiLine(TRUE)->setValue(''));
     $mainFields->push(HiddenField::create('id'));
     $mainFields->push(HiddenField::create('parent_id'));
     $parentFields->push($mainFields)->push($this->getSettingFields());
     return $parentFields;
 }
Пример #2
0
$renderer = new Renderer\PhpRenderer();
$renderer->addPath(dirname(__FILE__) . '/themes/bootstrap/templates/forms');
$factory = new AdapterFactorySimple();
$factory->setRenderer($renderer);
$categories = array(1 => 'Customer', 2 => 'Co-Worker', 3 => 'Family', 4 => 'Organisation', 5 => 'Prospect');
class DT extends DateTime
{
    public function __toString()
    {
        return $this->format('Y-m-d H:i:s');
    }
}
$interestList = array(array('id' => 3, 'name' => 'Play guitar', 'categoryId' => 2, 'start' => new DT('1998-10-25 10:00:00')), array('id' => 7, 'name' => 'Calligraphy', 'categoryId' => 4, 'start' => new DT('2004-05-21 13:00:00')), array('id' => 14, 'name' => 'Karate', 'categoryId' => 1, 'start' => new DT('1982-04-12 17:45:00')), array('id' => 78, 'name' => 'Calculating PI', 'categoryId' => 5, 'start' => new DT('1977-02-01 03:14:15')));
$columns = array('id' => 'InterestID', 'name' => 'Description', 'categoryId' => 'Category', 'start' => 'Interested since');
$itemForm = Form::create($factory);
$itemForm->push(HiddenField::create('id', 'ID'), TextField::create('name', 'Description'), SelectOneField::create('categoryId', 'Category')->setSrc($categories), TextField::create('start', 'Interested since'));
/**
 * @brief ...
 * @var \FormObject\Form
 */
$form = Form::create($factory);
$form->push($interests = EditManyField::create('items', 'Interests')->setValue($interestList)->setItemForm($itemForm));
$interests->addCssClass('draggable')->addCssClass('removable')->addCssClass('addable');
$nameValidator = new TextValidator();
$nameValidator->required = TRUE;
$nameValidator->minLength = 3;
$nameValidator->setMaxLength = 12;
$surnameValidator = new RequiredValidator();
$surnameValidator->required = TRUE;
$requiredValidator = new BooleanValidator();
$requiredValidator->mustBeTrue = TRUE;
 public function boot()
 {
     Form::addFormModifier(function (Form $form) {
         // Trigger auto action setter
         $form->getAction();
         $verb = strtoupper($form->getVerb());
         if (in_array($verb, ['PUT', 'PATCH', 'DELETE'])) {
             $form->push(HiddenField::create('_method')->setValue($verb));
         }
     });
 }