Example #1
0
 /**
  * Generates form buttons objects
  *
  * @param \Engine\Crud\Form\Extjs $form
  * @return string
  */
 public static function _(Form $form)
 {
     $primary = $form->getPrimaryField();
     $key = $primary ? $primary->getKey() : false;
     $code = "\n\n            buttonsGet: function(){\n                var me = this;\n\n                return [\n                    {\n                        text: 'Save',\n                        scope: me,\n                        formBind: true, //only enabled once the form is valid\n                        disabled: true,\n                        handler: me.onSubmit\n                    },\n                    {\n                        text: 'Reset',\n                        scope: me,\n                        handler: me.onReset\n                    }\n                ]\n            },\n            ";
     return $code;
 }
Example #2
0
 /**
  * Generates form fields object
  *
  * @param \Engine\Crud\Form\Extjs $form
  * @return string
  */
 public static function _(Form $form)
 {
     $code = "\n\n            fieldsGet: function(){\n                return [";
     $fields = [];
     foreach ($form->getFields() as $field) {
         if ($field instanceof Field) {
             if ($field instanceof Field\ArrayToSelect) {
                 $field->setAttrib("autoLoad", false);
                 $field->setAttrib("isLoaded", true);
                 $field->setAttrib("changeListener", true);
             }
             $fields[] = self::renderField($field);
         }
     }
     $code .= implode(",", $fields);
     $code .= "\n                ]\n            },";
     return $code;
 }
Example #3
0
 /**
  * Generates a widget to show a html form
  *
  * @param \Engine\Crud\Form\Extjs $form
  * @return string
  */
 public static function _(Form $form)
 {
     $title = $form->getTitle();
     $primary = $form->getPrimaryField();
     $key = $primary ? $primary->getKey() : false;
     $url = $form->getAction() . "/save";
     $code = "\n        Ext.define('" . static::getFormName() . "', {\n            extend: 'Ext.ux.crud.Form',\n            store: '" . static::getStoreName() . "',\n            alias: 'widget." . static::$_module . ucfirst(static::$_prefix) . "Form',\n            title: '" . $form->getTitle() . "',\n            bodyPadding: 5,\n            autoScroll:true,\n            waitMsgTarget: true,\n            fieldDefaults: {\n                labelAlign: 'right',\n                labelWidth: 85,\n                msgTarget: 'side'\n            },\n            defaultType: 'textfield',\n            defaults: {\n                width: 280\n            },\n            buttonAlign: 'left',\n            ";
     /*$width = $form->getWidth();
       if ($width) {
           $code .= "width: ".$width.",
           ";
       }
       $height = $form->getHeight();
       if ($width) {
           $code .= "height: ".$height.",
           ";
       }*/
     $code .= "url: '" . $url . "',\n            ";
     $code .= "link: '" . $form->getLink() . "',\n            ";
     if ($key) {
         $code .= "primaryKey: '" . $key . "',\n            ";
     }
     static::addRequires("Ext.form.field.*");
     static::addRequires("Ext.ux.crud.Form");
     $code .= "itemId: '" . static::$_module . ucfirst(static::$_prefix) . "Form',\n            ";
     return $code;
 }
Example #4
0
 /**
  * Init helper
  *
  * @param \Engine\Crud\Grid\Extjs|\Engine\Crud\Form\Extjs $element
  * @return string
  */
 public static function init($element)
 {
     static::$_module = \Phalcon\Text::camelize($element->getModuleName());
     static::$_prefix = \Phalcon\Text::camelize($element->getKey());
 }