本文整理汇总了PHP中Symfony\Component\Form\Form::has方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::has方法的具体用法?PHP Form::has怎么用?PHP Form::has使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Form\Form
的用法示例。
在下文中一共展示了Form::has方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createFilterQuery
protected function createFilterQuery(Form $form)
{
$qb = $this->getProfessionRepository()->createQueryBuilder('p')->select('p', 'pk')->leftJoin('p.professionkind', 'pk');
if ($form->get('name')->getNormData()) {
$qb->andWhere('p.name LIKE :name');
$qb->setParameter('name', '%' . $form->get('name')->getNormData() . '%');
}
if ($form->has('sort_field') && $form->get('sort_field')->getNormData()) {
$qb->orderBy('p.' . $form->get('sort_field')->getNormData(), $form->get('sort_order')->getNormData());
} else {
$qb->orderBy('p.id', 'ASC');
}
return $qb->getQuery();
}
示例2: createFilterQuery
protected function createFilterQuery(Form $form)
{
$qb = $this->getTraumaRepository()->createQueryBuilder('t')->select('t', 'e', 'enterp')->leftJoin('t.employee', 'e')->leftJoin('e.enterprise', 'enterp');
if ($form->get('name')->getNormData()) {
$qb->andWhere('t.name LIKE :name');
$qb->setParameter('name', '%' . $form->get('name')->getNormData() . '%');
}
if ($form->has('sort_field') && $form->get('sort_field')->getNormData()) {
$qb->orderBy('t.' . $form->get('sort_field')->getNormData(), $form->get('sort_order')->getNormData());
} else {
$qb->orderBy('t.id', 'ASC');
}
return $qb->getQuery();
}
示例3: createFilterQuery
protected function createFilterQuery(Form $form)
{
$qb = $this->getPageRepository()->createQueryBuilder('pk');
if ($form->get('title')->getNormData()) {
$qb->andWhere('pk.title LIKE :title');
$qb->setParameter('title', '%' . $form->get('title')->getNormData() . '%');
}
if ($form->has('sort_field') && $form->get('sort_field')->getNormData()) {
$qb->orderBy('pk.' . $form->get('sort_field')->getNormData(), $form->get('sort_order')->getNormData());
} else {
$qb->orderBy('pk.title', 'ASC');
}
return $qb->getQuery();
}
示例4: createFilterQuery
protected function createFilterQuery(Form $form)
{
$qb = $this->getTechnicalexaminationtypeRepository()->createQueryBuilder('tet');
if ($form->get('name')->getNormData()) {
$qb->andWhere('tet.name LIKE :name');
$qb->setParameter('name', '%' . $form->get('name')->getNormData() . '%');
}
if ($form->has('sort_field') && $form->get('sort_field')->getNormData()) {
$qb->orderBy('tet.' . $form->get('sort_field')->getNormData(), $form->get('sort_order')->getNormData());
} else {
$qb->orderBy('tet.id', 'ASC');
}
return $qb->getQuery();
}
示例5: createFilterQuery
protected function createFilterQuery(Form $form)
{
$qb = $this->getUserRepository()->createQueryBuilder('u');
if ($form->get('email')->getNormData()) {
$qb->andWhere('u.email LIKE :email');
$qb->setParameter('email', '%' . $form->get('email')->getNormData() . '%');
}
if ($form->has('sort_field') && $form->get('sort_field')->getNormData()) {
$qb->orderBy('u.' . $form->get('sort_field')->getNormData(), $form->get('sort_order')->getNormData());
} else {
$qb->orderBy('u.id', 'ASC');
}
return $qb->getQuery();
}
示例6: createFilterQuery
protected function createFilterQuery(Form $form)
{
$qb = $this->getEquipmentgroupRepository()->createQueryBuilder('eg');
if ($form->get('name')->getNormData()) {
$qb->andWhere('eg.name LIKE :name');
$qb->setParameter('name', '%' . $form->get('name')->getNormData() . '%');
}
if ($form->has('sort_field') && $form->get('sort_field')->getNormData()) {
$qb->orderBy('eg.' . $form->get('sort_field')->getNormData(), $form->get('sort_order')->getNormData());
} else {
$qb->orderBy('eg.id', 'ASC');
}
return $qb->getQuery();
}
示例7: createFilterQuery
protected function createFilterQuery(Form $form)
{
$qb = $this->getEquipmentRepository()->createQueryBuilder('e')->select('e', 'enterp', 'subd', 'esg')->leftJoin('e.subdivision', 'subd')->leftJoin('subd.enterprise', 'enterp')->leftJoin('e.equipmentsubgroup', 'esg');
if ($form->get('name')->getNormData()) {
$qb->andWhere('e.name LIKE :name');
$qb->setParameter('name', '%' . $form->get('name')->getNormData() . '%');
}
if ($form->has('sort_field') && $form->get('sort_field')->getNormData()) {
$qb->orderBy('e.' . $form->get('sort_field')->getNormData(), $form->get('sort_order')->getNormData());
} else {
$qb->orderBy('e.id', 'ASC');
}
return $qb->getQuery();
}
示例8: hasChild
private function hasChild(\Symfony\Component\Form\Form $form, $name)
{
if ($form->has($name)) {
// check duplicate name
$child = $form->get($name);
if (!$child->isValid()) {
$this->clearError($child);
}
return true;
}
foreach ($form as $child) {
if ($this->hasChild($child, $name)) {
return true;
}
}
return false;
}
示例9: createFilterQuery
protected function createFilterQuery(Form $form)
{
$qb = $this->getSubdivisionRepository()->createQueryBuilder('s')->select('s', 'sd')->leftJoin('s.enterprise', 'sd');
if ($form->get('name')->getNormData()) {
$qb->andWhere('s.name LIKE :name');
$qb->setParameter('name', '%' . $form->get('name')->getNormData() . '%');
}
if ($form->get('enterprise')->getNormData()) {
$qb->andWhere('IDENTITY(s.enterprise) = :enterprise');
$qb->setParameter('enterprise', $form->get('enterprise')->getNormData());
}
if ($form->has('sort_field') && $form->get('sort_field')->getNormData()) {
$qb->orderBy('s.' . $form->get('sort_field')->getNormData(), $form->get('sort_order')->getNormData());
} else {
$qb->orderBy('s.id', 'ASC');
}
return $qb->getQuery();
}
示例10: validate
public function validate(Form $form)
{
if (!$form->has('uploadedProductImages')) {
return TRUE;
}
if ($form->get('uploadedProductImages')->isRequired() && !array_filter($form->getData()->getUploadedProductImages())) {
$form->get('uploadedProductImages')->addError(new FormError($this->_translator->trans('product.uploaded_product_images.not_blank', [], 'validators')));
return FALSE;
}
foreach ($form->getData()->getUploadedProductImages() as $uploadedProductImage) {
$productImage = (new ProductImage())->setImageProductFile($uploadedProductImage);
$errors = $this->_validator->validate($productImage);
if (count($errors) === 0) {
return TRUE;
}
foreach ($errors as $error) {
$form->get('uploadedProductImages')->addError(new FormError($error->getMessage()));
}
return FALSE;
}
return TRUE;
}
示例11: getErrors
private function getErrors(\Symfony\Component\Form\Form $form, array &$elements, array &$forms, array &$errors)
{
$name = array_shift($elements);
if ($form->has($name)) {
$child = $form->get($name);
$forms[$name] = $child;
$errors[$name] = $child->getErrors();
if (empty($elements)) {
return $name;
}
return $this->getErrors($child, $elements, $forms, $errors);
} else {
if (count($forms)) {
$last_name = null;
foreach ($forms as $name => $child) {
$last_name = $name;
}
return $last_name;
}
return null;
}
}
示例12: createFilterQuery
protected function createFilterQuery(Form $form)
{
$qb = $this->getEmployeeRepository()->createQueryBuilder('e')->select('e', 'enterp', 'prof')->leftJoin('e.enterprise', 'enterp')->leftJoin('e.profession', 'prof');
if ($form->get('name')->getNormData()) {
$qb->andWhere('LOWER(e.firstname) LIKE LOWER(:name) OR LOWER(e.lastname) LIKE LOWER(:name) OR LOWER(e.middlename) LIKE LOWER(:name)');
$qb->setParameter('name', '%' . $form->get('name')->getNormData() . '%');
}
if ($form->get('enterprise')->getNormData()->count()) {
echo 'adsfasdf';
die;
$enterpriseIds = array_map(function ($item) {
return $item->getId();
}, $form->get('enterprise')->getNormData()->toArray());
$qb->andWhere('enterp.id IN (:enterprise)');
$qb->setParameter('enterprise', $enterpriseIds);
}
if ($form->has('sort_field') && $form->get('sort_field')->getNormData()) {
$qb->orderBy('e.' . $form->get('sort_field')->getNormData(), $form->get('sort_order')->getNormData());
} else {
$qb->orderBy('e.id', 'ASC');
}
return $qb->getQuery();
}
示例13: createActivity
public function createActivity(Activity $activity, Form $form)
{
// Apply context of Activity.
if (!$activity->getCampaign()) {
$activity->setCampaign($this->campaign);
} elseif (!$this->campaign) {
$this->campaign = $activity->getCampaign();
}
if (!$activity->getChannel()) {
$activity->setChannel($this->channel);
} elseif (!$this->channel) {
$this->channel = $activity->getChannel();
}
if (!$activity->getLocation()) {
$activity->setLocation($this->location);
} elseif (!$this->location) {
$this->location = $activity->getLocation();
}
// The Module's content.
$content = null;
// If Activity module is not set, then do it.
if (!$activity->getActivityModule()) {
$moduleService = $this->get('campaignchain.core.module');
$activity->setActivityModule($moduleService->getModule($this->activityBundleName, $this->activityModuleIdentifier));
}
// Does the Activity module relate to at least one Channel module?
$hasChannel = $activity->getActivityModule()->getChannelModules()->count();
// The Module's content.
$content = null;
$operation = new Operation();
if ($this->parameters['equals_operation']) {
if ($hasChannel) {
if (!$activity->getChannel()) {
$activity->setChannel($this->channel);
} elseif (!$this->channel) {
$this->channel = $activity->getChannel();
}
if (!$activity->getLocation()) {
$activity->setLocation($this->location);
} elseif (!$this->location) {
$this->location = $activity->getLocation();
}
}
// Allow the module to change some data based on its custom input.
if ($form->has($this->contentModuleFormName)) {
$this->handler->postFormSubmitNewEvent($activity, $form->get($this->contentModuleFormName)->getData());
// Allow a module's handler to modify the Activity data.
$activity = $this->handler->processActivity($activity, $form->get($this->contentModuleFormName)->getData());
}
// Get the operation module.
$operationService = $this->get('campaignchain.core.operation');
$operation = $operationService->newOperationByActivity($activity, $this->contentBundleName, $this->contentModuleIdentifier);
// Will the Operation create a Location, i.e. the Operation
// will be accessible through a URL after publishing?
if ($operation->getOperationModule()->ownsLocation()) {
// Get the location module.
$locationService = $this->get('campaignchain.core.location');
$locationModule = $locationService->getLocationModule($this->locationBundleName, $this->locationModuleIdentifier);
$contentLocation = new Location();
$contentLocation->setLocationModule($locationModule);
$contentLocation->setParent($activity->getLocation());
$contentLocation->setName($activity->getName());
$contentLocation->setStatus(Medium::STATUS_UNPUBLISHED);
$contentLocation->setOperation($operation);
$operation->addLocation($contentLocation);
if ($form->has($this->contentModuleFormName)) {
// Allow a module's handler to modify the Operation's Location.
$contentLocation = $this->handler->processContentLocation($contentLocation, $form->get($this->contentModuleFormName)->getData());
}
}
if ($form->has($this->contentModuleFormName)) {
// Process the Operation's content.
$content = $this->handler->processContent($operation, $form->get($this->contentModuleFormName)->getData());
}
if ($content) {
// Link the Operation details with the operation.
$content->setOperation($operation);
}
} elseif (count($this->parameters['operations']) > 1) {
$content = $this->handler->processMultiOperationMultiContent($activity, $form, $this->parameters['operations']);
}
$em = $this->getDoctrine()->getManager();
// Make sure that data stays intact by using transactions.
try {
$em->getConnection()->beginTransaction();
$em->persist($activity);
if (!$content) {
$content = $this->handler->processSingleContentMultiOperation($activity, $form);
}
if ($content) {
$em->persist($content);
}
// We need the activity ID for storing the hooks. Hence we must
// flush here.
$em->flush();
$hookService = $this->get('campaignchain.core.hook');
/** @var Activity $activity */
$activity = $hookService->processHooks($this->parameters['bundle_name'], $this->parameters['module_identifier'], $activity, $form, true);
// Check if the content can be executed.
if (isset($this->validators['operations']) && $content) {
//.........这里部分代码省略.........
示例14: contentAfterFlush
protected function contentAfterFlush($response, $action, $row)
{
$adminFormEvent = new AdminFormEvent($action, $row);
$this->get('event_dispatcher')->dispatch(AdminFormEvent::AFTERFLUSH_CONTENT, $adminFormEvent);
$langs = $this->get('nyrocms')->getLocaleNames($row);
$defaultLocale = $this->get('nyrocms')->getDefaultLocale($row);
unset($langs[$defaultLocale]);
$om = $this->get('nyrocms_db')->getObjectManager();
$propertyAccess = PropertyAccess::createPropertyAccessor();
foreach ($langs as $lg => $lang) {
$row->setTranslatableLocale($lg);
$om->refresh($row);
foreach ($this->contentTranslationFields as $field => $options) {
$fieldName = 'lang_' . $lg . '_' . $field;
if ($this->contentForm->has($fieldName)) {
$propertyAccess->setValue($row, $field, $this->contentForm->get($fieldName)->getData());
}
}
$this->get('nyrocms_admin')->updateContentUrl($row, $action == self::EDIT);
$om->flush();
}
}
示例15: getFormDebug
public function getFormDebug(\Symfony\Component\Form\Form $form)
{
if (!$form->has('sf_admin_form_debug')) {
return;
}
$url = $form->get('sf_admin_form_debug')->getData();
return $url;
}