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; }
public function getFormOptions() { $options = parent::getFormOptions(); if (0) { $writer = new \Symforce\AdminBundle\Compiler\Generator\PhpWriter(); $writer->writeln('new \\Symfony\\Component\\Security\\Core\\Validator\\Constraints\\UserPassword(array(')->indent()->outdent()->writeln('))'); $options['constraints'][] = $this->compilePhpCode($writer->getContent()); if (null !== $this->repeat) { $options['type'] = 'password'; //$options['invalid_message'] = 'The password fields must match.', $options['first_options'] = array('label' => $_options['label'], 'required' => $_options['required']); $options['second_options'] = array('label_render' => false, 'required' => $_options['required']); } } if (!property_exists($this->admin_object->class_name, $this->salt)) { $this->throwError("salt property(%s), not exist in class(%s)", $this->salt, $this->admin_object->class_name); } if (!property_exists($this->admin_object->class_name, $this->real_password)) { $this->throwError("real_password property(%s), not exist in class(%s)", $this->real_password, $this->admin_object->class_name); } if ($this->class_property === $this->real_password) { $this->throwError("real_password property(%s) can not be it self, class(%s)", $this->real_password, $this->admin_object->class_name); } if ($this->class_property === $this->salt) { $this->throwError("salt property(%s) can not be it self, class(%s)", $this->salt, $this->admin_object->class_name); } $options['salt_property'] = $this->salt; $options['password_property'] = $this->real_password; $options['required'] = $this->compilePhpCode('$action->isCreateAction()'); return $options; }
public function getFormOptions() { $options = parent::getFormOptions(); $writer = new \Symforce\AdminBundle\Compiler\Generator\PhpWriter(); $writer->writeln('new \\Symforce\\AdminBundle\\Form\\Constraints\\Json(array(')->indent()->outdent()->writeln('))'); $options['constraints'][] = $this->compilePhpCode($writer->getContent()); return $options; }
public function getFormOptions() { $options = parent::getFormOptions(); $writer = new \Symforce\AdminBundle\Compiler\Generator\PhpWriter(); $writer->writeln('new \\Symfony\\Component\\Validator\\Constraints\\Email(array(')->indent()->writeln('"checkMX" => false , ')->outdent()->writeln('))'); $options['constraints'][] = $this->compilePhpCode($writer->getContent()); return $options; }
public function getFormOptions() { $options = parent::getFormOptions(); if (null !== $this->max_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\\Url(array(')->indent()->outdent()->writeln('))'); $options['constraints'][] = $this->compilePhpCode($writer->getContent()); } return $options; }