本文整理汇总了PHP中Symfony\Component\DomCrawler\Form::has方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::has方法的具体用法?PHP Form::has怎么用?PHP Form::has使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\DomCrawler\Form
的用法示例。
在下文中一共展示了Form::has方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isValid
public function isValid(Form $form)
{
if ($form->has('token')) {
$values = $form->getValues();
$values['token'] = 'modified by csrf scanner';
$form->setValues($values);
$this->client->submit($form);
$status = $this->client->getResponse()->getStatus();
if (403 == $status) {
return true;
}
$this->message = "403 response expected, but got a {$status}";
} else {
$this->message = "No 'token' input field found";
}
return false;
}
示例2: getFormFieldValues
/**
* Returns an array of values for the field with the passed name. Usually
* the array consists of a single value. Used by proceedSeeInField
*
* @param Form $form
* @param string $fieldName
* @return array
*/
private function getFormFieldValues(Form $form, $fieldName)
{
$strField = $this->getSubmissionFormFieldName($fieldName);
$values = [];
if ($form->has($strField)) {
$fields = $form->get($strField);
// $form->get returns an array for fields with names ending in []
if (!is_array($fields)) {
$fields = [$fields];
}
foreach ($fields as $field) {
if (!$field->hasValue()) {
continue;
}
// $field->getValue may return an array (multi-select for example) or a string value
$values = array_merge($values, (array) $field->getValue());
}
}
return $values;
}
示例3: isValid
public function isValid(Form $form)
{
return $form->has('token');
}