Exemple #1
0
 public function getFormOptions()
 {
     $options = parent::getFormOptions();
     $options['choices'] = $this->compilePhpCode('$this->getOwnerFormChoices($object)');
     $options['sf_admin_class'] = $this->admin_object->class_name;
     return $options;
 }
Exemple #2
0
 public function getFormOptions()
 {
     $options = parent::getFormOptions();
     if (null !== $this->min || null !== $this->max) {
         $max = $this->max ?: 0x7fffff;
         $min = $this->min ?: 0;
         $writer = new \Symforce\AdminBundle\Compiler\Generator\PhpWriter();
         $writer->writeln('new \\Symfony\\Component\\Validator\\Constraints\\Range(array(')->indent()->writeln(sprintf(' "min" => %d, ', $min))->writeln(sprintf(' "max" => %d, ', $max))->outdent()->writeln('))');
         $options['constraints'][] = $this->compilePhpCode($writer->getContent());
         $options['attr']['min'] = $min;
         $options['attr']['max'] = $max;
     }
     if ($this->greater_than || $this->less_than) {
         $writer = new \Symforce\AdminBundle\Compiler\Generator\PhpWriter();
         $writer->writeln('new \\Symforce\\AdminBundle\\Form\\Constraints\\CompareValidator(array(')->indent();
         if ($this->greater_than) {
             $writer->writeln(sprintf(' "greater_than" => %s, ', var_export($this->greater_than, 1)));
         }
         if ($this->less_than) {
             $writer->writeln(sprintf(' "less_than" => %s, ', var_export($this->less_than, 1)));
         }
         if ($this instanceof Range) {
             if ($this->_unit) {
                 $writer->writeln(sprintf(' "unit" => %s, ', var_export(array($this->_unit->getPath(), $this->_unit->getDomain()), 1)));
             }
         }
         $writer->outdent()->writeln('), $this)');
         $options['subscribers'][] = $this->compilePhpCode($writer->getContent());
     }
     return $options;
 }
Exemple #3
0
 public function getFormOptions()
 {
     $options = parent::getFormOptions();
     $options['choices'] = $this->compilePhpCode('$this->getWorkflowFormChoices($object)');
     $options['sf_admin_class'] = $this->admin_object->class_name;
     $options['expanded'] = true;
     $options['widget_type'] = 'inline';
     return $options;
 }
Exemple #4
0
 public function getFormOptions()
 {
     $admin_class = $this->admin_object->getCompileClass();
     $admin_class->addLazyArray('form_elements', $this->class_property, array('ext' => $this->extentions, 'max' => $this->max_size));
     $this->admin_object->generator->setDoctrineConfig($this->admin_object->class_name, 'file', $this->class_property);
     $options = parent::getFormOptions();
     $options['sf_admin_class'] = $this->admin_object->class_name;
     $options['sf_admin_property'] = $this->class_property;
     $options['sf_admin_name'] = $this->admin_object->name;
     $options['sf_admin_id'] = $this->admin_object->property_id_name;
     $options['required'] = false;
     $options['accept_file_type'] = join('|', $this->extentions);
     $options['max_file_size'] = $this->max_size;
     return $options;
 }
Exemple #5
0
 public function getFormOptions()
 {
     $_options = parent::getFormOptions();
     /**
      * @TODO check $this->jsclass call js instance 
      */
     $options = array('format' => $this->format, 'picker' => 'datetime', 'attr' => array('type' => 'text', 'class' => 'datepicker not-removable form-control', 'data-format' => $this->format));
     if (null !== $this->greater_than) {
         $options['greater_than'] = $this->greater_than;
     }
     if (null !== $this->less_than) {
         $options['less_than'] = $this->less_than;
     }
     return array_merge($_options, $options);
 }
Exemple #6
0
 public function getFormOptions()
 {
     $options = parent::getFormOptions();
     if (null !== $this->trim) {
         $options['trim'] = $this->trim;
     }
     if (null !== $this->min_length || null !== $this->max_length) {
         $max = $this->max_length ?: 0xff;
         $min = $this->min_length ?: 0;
         $writer = new \Symforce\AdminBundle\Compiler\Generator\PhpWriter();
         $writer->writeln('new \\Symfony\\Component\\Validator\\Constraints\\Length(array(')->indent()->writeln(sprintf(' "min" => %d, ', $min))->writeln(sprintf(' "max" => %d, ', $max))->outdent()->writeln('))');
         $options['constraints'][] = $this->compilePhpCode($writer->getContent());
     }
     return $options;
 }
Exemple #7
0
 public function getFormOptions()
 {
     $options = parent::getFormOptions();
     $options['sf_admin_class'] = $this->admin_object->class_name;
     $options['sf_admin_property'] = $this->class_property;
     $options['copy_property'] = $this->copy_property;
     $map = $this->admin_object->orm_metadata->getAssociationMapping($this->class_property);
     if (\Doctrine\ORM\Mapping\ClassMetadataInfo::MANY_TO_MANY === $map['type']) {
     } else {
     }
     $options['target_class'] = $map['targetEntity'];
     if (!$this->admin_object->generator->hasAdminClass($options['target_class'])) {
         throw new \Exception("oops");
     }
     return $options;
 }
Exemple #8
0
 public function getFormOptions()
 {
     /**
      * @todo add code to detect infinite loop
      */
     $map = $this->admin_object->orm_metadata->getAssociationMapping($this->class_property);
     $parent_class = $map['targetEntity'];
     foreach ($this->copy_properties as $from_property => $to_property) {
         if (!is_string($from_property)) {
             $this->throwError("copy_properties source property must be string, you set:%s!", gettype($from_property));
         }
         if (!property_exists($this->admin_object->class_name, $from_property)) {
             $this->throwError("copy_properties source property:%s not exists!", $from_property);
         }
         if (!is_string($to_property)) {
             $this->throwError("copy_properties target:%s property must be string, you set:%s!", $parent_class, gettype($to_property));
         }
         if (!property_exists($parent_class, $to_property)) {
             $this->throwError("copy_properties target:%s->%s not exists!", $parent_class, $to_property);
         }
     }
     $options = parent::getFormOptions();
     return $options;
 }
 public function getFormOptions()
 {
     $options = parent::getFormOptions();
     unset($options['required']);
     return $options;
 }
Exemple #10
0
 public function getFormOptions()
 {
     $_options = parent::getFormOptions();
     $options = array('attr' => array('type' => 'text', 'class' => 'colorpicker form-control not-removable'));
     return array_merge($_options, $options);
 }
Exemple #11
0
 public function getFormOptions()
 {
     $admin = $this->admin_object->getCompileClass();
     $choices = $this->getChoices();
     if ($choices) {
         $tr_path_map = array();
         foreach ($choices as $option) {
             $this->fixOption($option);
             $tr_path_map[$option->value] = array($option->getLabel()->getPath(), $option->getLabel()->getDomain() !== $this->admin_object->tr_domain);
         }
         $admin->addLazyArray('form_choices', $this->class_property, $tr_path_map);
     }
     $options = parent::getFormOptions();
     if (null !== $this->choice_code) {
         if ($this->choices) {
             $this->throwError(' can not use choices_code with choices');
         }
         if (false == strpos($this->choice_code, '$')) {
             $options['choices'] = $this->compilePhpCode(sprintf('$this->%s($object)', $this->choice_code));
         } else {
             $options['choices'] = $this->compilePhpCode($this->choice_code);
         }
     } else {
         $choices = $this->getChoices();
         if (null !== $choices) {
             $choice_options = array();
             foreach ($choices as $option) {
                 if (!is_object($option)) {
                     \Dev::dump($option);
                     exit;
                 }
                 $this->fixOption($option);
                 $choice_options[$option->value] = $option->getLabel()->getPhpCode();
             }
             $options['choices'] = $choice_options;
         }
     }
     if ($this->expanded) {
         $options['expanded'] = true;
     }
     if ($this->multiple) {
         $options['multiple'] = true;
     }
     if ($this->virtual) {
         $options['virtual'] = true;
     }
     if (null === $this->empty_value) {
         if ($this->isNullable()) {
             // for select, this allow empty value
             if (!$this->expanded && !$this->multiple) {
                 $options['empty_value'] = null;
                 $options['empty_data'] = '';
             }
         } else {
             $this->required = true;
         }
     }
     if ($this->empty_value) {
         $options['empty_value'] = $this->empty_value;
         $options['empty_data'] = $this->empty_data;
         $options['required'] = false;
         $this->required = false;
     }
     if (null !== $this->preferred_choices) {
         if (!$this->expanded) {
             throw new \Exception("preferred_choices need expanded=true");
         }
         $options['preferred_choices'] = is_array($this->preferred_choices) ? $this->preferred_choices : array($this->preferred_choices);
     }
     return $options;
 }