Ejemplo n.º 1
0
Archivo: Basic.php Proyecto: xepan/base
 function init()
 {
     parent::init();
     // add add-on locations to pathfinder
     $l = $this->api->locate('addons', __NAMESPACE__, 'location');
     $addon_location = $this->api->locate('addons', __NAMESPACE__);
     $this->api->pathfinder->addLocation(array('js' => 'js', 'css' => 'templates/css'))->setBasePath($this->api->pathfinder->base_location->base_path . '/../' . $addon_location)->setBaseURL($this->api->pm->base_path . '../' . $addon_location);
     // $this->api->pathfinder->addLocation($addon_location, array(
     //     'js'  => 'js',
     //     'css' => 'templates/css',
     // ))->setParent($l);
     // add additional form field
     $name = preg_replace('/_id$/', '', $this->short_name);
     $caption = null;
     if ($this->owner->model) {
         if ($f = $this->owner->model->getField($this->short_name)) {
             $caption = $f->caption();
         }
     }
     $this->other_field = $this->owner->addField('line', $name, $caption);
     if ($this->hint) {
         $text = sprintf($this->hint, $this->min_length, $this->limit_rows);
         if ($this->hint_show_as == 'placeholder') {
             $this->other_field->setAttr('placeholder', $text);
         } elseif ($this->hint_show_as == 'hint') {
             $this->other_field->setFieldHint($text);
         }
     }
     // move hidden ID field after other field. Otherwise it breaks :first->child CSS in forms
     $this->js(true)->appendTo($this->other_field->js()->parent());
     // Set default options
     if ($this->min_length) {
         $this->options['minLength'] = $this->min_length;
     }
 }
Ejemplo n.º 2
0
 public function init()
 {
     parent::init();
     // add add-on locations to pathfinder
     /*
     $l = $this->app->locate('addons', __NAMESPACE__, 'location');
     $addon_location = $this->app->locate('addons', __NAMESPACE__);
     $this->app->pathfinder->addLocation($addon_location, array(
         'js'  => 'public/js',
         'css' => 'public/css',
     ))->setParent($l);
     */
     /* this way it works but looks very cryptic
        $l = $this->app->locate('addons', __NAMESPACE__);
        $this->app->pathfinder->public_location
            ->addRelativeLocation('../'.$l, ['public'=>'public','js'=>'public/js','css'=>'public/css']);
        */
     // add additional form field
     $name = preg_replace('/_id$/', '', $this->short_name);
     $caption = null;
     if ($this->owner->model) {
         if ($f = $this->owner->model->getElement($this->short_name)) {
             if ($this->owner->model instanceof \atk4\data\Model) {
                 $caption = isset($f->ui['caption']) ? $f->ui['caption'] : null;
             } else {
                 $caption = $f->caption();
             }
         }
     }
     $this->other_field = $this->owner->addField('line', $name, $caption);
     if ($this->hint) {
         $text = sprintf($this->hint, $this->min_length, $this->limit_rows);
         if ($this->hint_show_as == 'placeholder') {
             $this->other_field->setAttr('placeholder', $text);
         } elseif ($this->hint_show_as == 'hint') {
             $this->other_field->setFieldHint($text);
         }
     }
     // move hidden ID field after other field. Otherwise it breaks :first->child CSS in forms
     $this->js(true)->appendTo($this->other_field->js()->parent());
     // Set default options
     if ($this->min_length) {
         $this->options['minLength'] = $this->min_length;
     }
 }
Ejemplo n.º 3
0
 function init()
 {
     $this->name = $this->short_name = 'MAX_FILE_SIZE';
     parent::init();
     $this->no_save = true;
 }