本文整理汇总了PHP中Symfony\Component\Form\FormConfigInterface::getOption方法的典型用法代码示例。如果您正苦于以下问题:PHP FormConfigInterface::getOption方法的具体用法?PHP FormConfigInterface::getOption怎么用?PHP FormConfigInterface::getOption使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Form\FormConfigInterface
的用法示例。
在下文中一共展示了FormConfigInterface::getOption方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFormRuleMessage
protected function getFormRuleMessage(FormConfigInterface $config)
{
// Get correct error message if one is set.
if ($config->hasOption('invalid_message')) {
$params = $config->getOption('invalid_message_parameters');
return new RuleMessage($config->getOption('invalid_message'), is_array($params) ? $params : array());
}
return null;
}
示例2: prepareOptions
/**
* Prepare form options from config
*
* @param FormConfigInterface $config
*
* @return $config
*/
protected function prepareOptions(FormConfigInterface $config)
{
$options = array('disabled' => true, 'read_only' => true);
if ($help = $config->getOption('help')) {
$options['help'] = $help;
}
if ($label = $config->getOption('label')) {
$options['label'] = $label;
}
if ($select2 = $config->getOption('select2')) {
$options['select2'] = $select2;
}
return $options;
}
示例3: assertFormConfig
/**
* @param array $expectedConfig
* @param FormConfigInterface $actualConfig
*/
protected function assertFormConfig(array $expectedConfig, FormConfigInterface $actualConfig)
{
foreach ($expectedConfig as $key => $value) {
$this->assertTrue($actualConfig->hasOption($key));
$this->assertEquals($value, $actualConfig->getOption($key));
}
}
示例4: processDateTime
private function processDateTime(FormView $view, FormConfigInterface $config, FormRuleContextBuilder $context)
{
if ($config->getOption('format') !== DateTimeType::HTML5_FORMAT) {
return;
}
$rules = new RuleCollection();
$rules->set('date', new TransformerRule('date', true, $this->getFormRuleMessage($config)));
$context->add($view, $rules);
}
示例5: validateChoiceLoaderForDefaultOptions
protected function validateChoiceLoaderForDefaultOptions(FormConfigInterface $config)
{
$this->assertNull($config->getOption('choice_loader'));
}
示例6: validateChoiceLoaderForDefaultOptions
protected function validateChoiceLoaderForDefaultOptions(FormConfigInterface $config)
{
$this->assertInstanceOf('Symfony\\Bridge\\Doctrine\\Form\\ChoiceList\\DoctrineChoiceLoader', $config->getOption('choice_loader'));
}
示例7: assignFormTypeValues
/**
* @param \Smarty_Internal_Template $template
* @param FormConfigInterface $formFieldConfig
* @param FormView $formFieldView
*/
protected function assignFormTypeValues($template, $formFieldConfig, $formFieldView)
{
$formFieldType = $formFieldConfig->getType()->getInnerType();
/* access to choices */
if ($formFieldType instanceof ChoiceType) {
$template->assign("choices", $formFieldView->vars['choices']);
}
/* access to collections */
if ($formFieldType instanceof CollectionType) {
if (true === $formFieldConfig->getOption('prototype')) {
} else {
/* access to choices */
if (isset($formFieldView->vars['choices'])) {
$template->assign("choices", $formFieldView->vars['choices']);
}
}
}
/* access to date */
if ($formFieldType instanceof DateType || $formFieldType instanceof DateTimeType || $formFieldType instanceof BirthdayType) {
if ('choice' === $formFieldConfig->getOption('widget')) {
/* access to years */
if ($formFieldConfig->getOption('years')) {
$formFieldView->vars['years'] = $formFieldConfig->getOption('years');
$template->assign("years", $formFieldView->vars['years']);
}
/* access to month */
if ($formFieldConfig->getOption('months')) {
$formFieldView->vars['months'] = $formFieldConfig->getOption('months');
$template->assign("months", $formFieldView->vars['months']);
}
/* access to days */
if ($formFieldConfig->getOption('days')) {
$formFieldView->vars['days'] = $formFieldConfig->getOption('days');
$template->assign("days", $formFieldView->vars['days']);
}
/* access to empty_value */
if ($formFieldConfig->getOption('empty_value')) {
$formFieldView->vars['empty_value'] = $formFieldConfig->getOption('empty_value');
$template->assign("empty_value", $formFieldView->vars['empty_value']);
}
}
}
/* access to thelia type */
if ($formFieldType instanceof TheliaType) {
$template->assign("formType", $formFieldView->vars['type']);
switch ($formFieldView->vars['type']) {
case "choice":
if (!isset($formFieldView->vars['options']['choices']) || !is_array($formFieldView->vars['options']['choices'])) {
//throw new
}
$choices = array();
foreach ($formFieldView->vars['options']['choices'] as $value => $choice) {
$choices[] = new ChoiceView($value, $value, $choice);
}
$template->assign("choices", $choices);
break;
}
}
}
示例8: assignFormTypeValues
/**
* @param \Smarty_Internal_Template $template
* @param FormConfigInterface $formFieldConfig
* @param FormView $formFieldView
*/
protected function assignFormTypeValues($template, $formFieldConfig, $formFieldView)
{
$formFieldType = $formFieldConfig->getType()->getInnerType();
/* access to choices */
if ($formFieldType instanceof ChoiceType) {
$template->assign("choices", $formFieldView->vars['choices']);
}
/* access to collections */
if ($formFieldType instanceof CollectionType) {
if (true === $formFieldConfig->getOption('prototype')) {
} else {
/* access to choices */
if (isset($formFieldView->vars['choices'])) {
$template->assign("choices", $formFieldView->vars['choices']);
}
}
}
/* access to thelia type */
if ($formFieldType instanceof TheliaType) {
$template->assign("formType", $formFieldView->vars['type']);
switch ($formFieldView->vars['type']) {
case "choice":
if (!isset($formFieldView->vars['options']['choices']) || !is_array($formFieldView->vars['options']['choices'])) {
//throw new
}
$choices = array();
foreach ($formFieldView->vars['options']['choices'] as $value => $choice) {
$choices[] = new ChoiceView($value, $value, $choice);
}
$template->assign("choices", $choices);
break;
}
}
}
示例9: getFormRuleMessage
protected function getFormRuleMessage(FormConfigInterface $config)
{
// Get correct error message if one is set.
if ($config->hasOption('invalid_message')) {
// TODO support invalid_message_parameters
return new RuleMessage($config->getOption('invalid_message'));
}
return null;
}