本文整理汇总了PHP中Symfony\Component\Form\Form::remove方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::remove方法的具体用法?PHP Form::remove怎么用?PHP Form::remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Form\Form
的用法示例。
在下文中一共展示了Form::remove方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
function it_does_not_remove_user_form_type_if_users_data_is_submitted(FormEvent $event, Form $form)
{
$event->getData()->willReturn(['user' => ['plainPassword' => 'test']]);
$event->getForm()->shouldNotBeCalled();
$form->remove('user')->shouldNotBeCalled();
$this->preSubmit($event);
}
示例2: aggregatePluralValues
/**
* @param array $data
* @param Form $form
* @return string
*/
protected function aggregatePluralValues(&$data, $form)
{
$labelManager = $this->labelManager;
$labelValue = '';
$standardRules = array();
$explicitRules = array();
foreach ($data as $property => $value) {
if (0 === strpos($property, self::PLURAL_FIELD_PREFIX)) {
$pluralForm = substr($property, strlen(self::PLURAL_FIELD_PREFIX));
if (is_numeric($pluralForm)) {
$standardRules[$pluralForm] = $value;
} else {
$explicitRules[$pluralForm] = sprintf('%s %s', $labelManager->reverseTransformInterval($pluralForm), $value);
}
$form->remove($property);
unset($data[$property]);
}
}
if ($standardRules) {
$labelValue = implode('|', $standardRules);
if ($explicitRules) {
$labelValue .= '|' . implode('|', $explicitRules);
}
} elseif ($explicitRules) {
$labelValue = implode('|', $explicitRules);
}
return $labelValue;
}
示例3: removeDuplicateFields
/**
* Remove duplicate fields from the form
*
* @param Form $form
* @param array &$existingFields
*/
protected function removeDuplicateFields(Form $form, array &$existingFields)
{
foreach (array_keys($form->all()) as $field) {
if (in_array($field, $existingFields)) {
$form->remove($field);
} else {
$existingFields[] = $field;
}
}
}
开发者ID:alexisfroger,项目名称:pim-community-dev,代码行数:16,代码来源:RemoveDuplicateJobConfigurationSubscriber.php
示例4: removeFields
/**
* This function remove fields available if there are not present in the $data array
* The data array might come from $request->request->all().
*
* This can be usefull if you don't want to send all fields will building an api. As missing
* fields will be threated like null values.
*
* @param array $data
* @param Form $form
*/
public static function removeFields(array $data, Form $form)
{
$diff = array_diff(array_keys($form->all()), array_keys($data));
foreach ($diff as $key) {
$form->remove($key);
}
foreach ($data as $name => $value) {
if (!is_array($value)) {
continue;
}
self::removeFields($value, $form[$name]);
}
}
示例5: __construct
public function __construct(Form $form, Request $request, UserManagerInterface $userManager)
{
// borrando campos no necesarios
$form->remove('gender');
$form->remove('website');
$form->remove('biography');
$form->remove('timezone');
$form->remove('phone');
$form->remove('locale');
$form->remove('dateOfBirth');
// cargando nuevos campos
$form->add('username', null, array('label' => 'Name of User'));
$form->add('email');
$form->add('organization');
// $form->add('gravatar', 'file', array(
// 'mapped' => false,
// 'attr' => ['class' => 'filestyle','data-buttonBefore'=> 'true', 'data-buttonText' => 'Choose file' ]
// ));
parent::__construct($form, $request, $userManager);
}
示例6: testRemoveUnsetsFieldParent
public function testRemoveUnsetsFieldParent()
{
$form = new Form('author');
$field = $this->createMockField('firstName');
$field->expects($this->exactly(2))->method('setParent');
// PHPUnit fails to compare subsequent method calls with different arguments
$form->add($field);
$form->remove('firstName');
}
示例7: cleanForm
/**
* Remove unnecessary fields from form
*
* @param array $requestData
* @param Form $form
*/
private function cleanForm($requestData, Form $form)
{
$allowedField = array_keys($requestData);
/** @var FormInterface[] $formFields */
$formFields = $form->all();
foreach ($formFields as $formField) {
$fieldName = $formField->getName();
if (!in_array($fieldName, $allowedField)) {
$form->remove($fieldName);
}
}
}
示例8: filterForm
private function filterForm(Form $form, $array_path, $level = 0)
{
$formChildren = $form->all();
foreach ($formChildren as $formChild) {
if ($formChild->getName() != $array_path[$level] && $formChild->getName() != '_token' && $formChild->getName() != 'submit') {
$form->remove($formChild->getName());
} else {
if (count($array_path) > $level + 1 && $formChild->getName() != '_token' && $formChild->getName() != 'submit') {
$this->filterForm($formChild, $array_path, $level + 1);
}
}
}
}