Added brand logo image selection
This commit is contained in:
@@ -58,6 +58,7 @@ class Brand extends BaseAction implements EventSubscriberInterface
|
||||
|
||||
$brand
|
||||
->setVisible($event->getVisible())
|
||||
->setLogoImageId(intval($event->getLogoImageId()) == 0 ? null : $event->getLogoImageId())
|
||||
->setLocale($event->getLocale())
|
||||
->setTitle($event->getTitle())
|
||||
->setDescription($event->getDescription())
|
||||
|
||||
@@ -80,13 +80,14 @@ class BrandController extends AbstractSeoCrudController
|
||||
|
||||
// Prepare the data that will hydrate the form
|
||||
$data = [
|
||||
'id' => $object->getId(),
|
||||
'locale' => $object->getLocale(),
|
||||
'title' => $object->getTitle(),
|
||||
'chapo' => $object->getChapo(),
|
||||
'description' => $object->getDescription(),
|
||||
'postscriptum' => $object->getPostscriptum(),
|
||||
'visible' => $object->getVisible() ? true : false
|
||||
'id' => $object->getId(),
|
||||
'locale' => $object->getLocale(),
|
||||
'title' => $object->getTitle(),
|
||||
'chapo' => $object->getChapo(),
|
||||
'description' => $object->getDescription(),
|
||||
'postscriptum' => $object->getPostscriptum(),
|
||||
'visible' => $object->getVisible() ? true : false,
|
||||
'logo_image_id' => $object->getLogoImageId()
|
||||
];
|
||||
|
||||
// Setup the object form
|
||||
@@ -123,12 +124,13 @@ class BrandController extends AbstractSeoCrudController
|
||||
$brandUpdateEvent = new BrandUpdateEvent($formData['id']);
|
||||
|
||||
$brandUpdateEvent
|
||||
->setLogoImageId($formData['logo_image_id'])
|
||||
->setVisible($formData['visible'])
|
||||
->setLocale($formData['locale'])
|
||||
->setTitle($formData['title'])
|
||||
->setChapo($formData['chapo'])
|
||||
->setDescription($formData['description'])
|
||||
->setPostscriptum($formData['postscriptum'])
|
||||
->setVisible($formData['visible'])
|
||||
;
|
||||
|
||||
return $brandUpdateEvent;
|
||||
|
||||
@@ -24,6 +24,7 @@ class BrandUpdateEvent extends BrandCreateEvent
|
||||
protected $chapo;
|
||||
protected $description;
|
||||
protected $postscriptum;
|
||||
protected $logo_image_id;
|
||||
|
||||
/**
|
||||
* @param int $brandId
|
||||
@@ -112,4 +113,22 @@ class BrandUpdateEvent extends BrandCreateEvent
|
||||
{
|
||||
return $this->postscriptum;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $logo_image_id
|
||||
* @return $this
|
||||
*/
|
||||
public function setLogoImageId($logo_image_id)
|
||||
{
|
||||
$this->logo_image_id = $logo_image_id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getLogoImageId()
|
||||
{
|
||||
return $this->logo_image_id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,6 +183,7 @@ class Brand extends BaseI18nLoop implements PropelSearchLoopInterface, SearchLoo
|
||||
->set("META_KEYWORDS" , $brand->getVirtualColumn('i18n_META_KEYWORDS'))
|
||||
->set("POSITION" , $brand->getPosition())
|
||||
->set("VISIBLE" , $brand->getVisible())
|
||||
->set("LOGO_IMAGE_ID" , $brand->getLogoImageId())
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
|
||||
@@ -159,15 +159,19 @@ class AdminUtilities extends AbstractSmartyPlugin
|
||||
|
||||
public function buildFormFieldLabel($params, &$smarty)
|
||||
{
|
||||
$form = $this->getParam($params, 'form', false);
|
||||
$field_name = $this->getParam($params, 'name', false);
|
||||
$label_attr = $this->getParam($params, 'label_attr', array());
|
||||
$form = $this->getParam($params, 'form', false);
|
||||
$field_name = $this->getParam($params, 'name', false);
|
||||
$label_attr = $this->getParam($params, 'label_attr', false);
|
||||
|
||||
return $this->fetchSnippet($smarty, 'forms'.DS.'form-label', array(
|
||||
'form' => $form,
|
||||
'field_name' => $field_name,
|
||||
'label_attr' => $label_attr
|
||||
));
|
||||
$args = [
|
||||
'form' => $form,
|
||||
'field_name' => $field_name,
|
||||
];
|
||||
|
||||
if ($label_attr !== false)
|
||||
$args['label_attr'] = $label_attr;
|
||||
|
||||
return $this->fetchSnippet($smarty, 'forms'.DS.'form-label', $args);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -53,6 +53,15 @@ class BrandModificationForm extends BrandCreationForm
|
||||
]
|
||||
]
|
||||
)
|
||||
->add("logo_image_id", "integer", [
|
||||
'constraints' => [ ],
|
||||
'required' => false,
|
||||
'label' => Translator::getInstance()->trans('Select the brand logo'),
|
||||
'label_attr' => [
|
||||
'for' => 'mode',
|
||||
'help' => Translator::getInstance()->trans("Select the brand logo amongst the brand images")
|
||||
]
|
||||
])
|
||||
;
|
||||
|
||||
// Add standard description fields, excluding title and locale, which are already defined
|
||||
|
||||
@@ -40,10 +40,8 @@ class ProductModificationForm extends ProductCreationForm
|
||||
'label' => Translator::getInstance()->trans('Brand / Supplier'),
|
||||
'label_attr' => [
|
||||
'for' => 'mode',
|
||||
],
|
||||
'attr' => [
|
||||
'help' => Translator::getInstance()->trans("Select the product brand, or supplier."),
|
||||
]
|
||||
],
|
||||
])
|
||||
;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user