本文整理匯總了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');
}