Add validation for Store configuration
This commit is contained in:
@@ -23,9 +23,6 @@
|
|||||||
namespace Thelia\Form;
|
namespace Thelia\Form;
|
||||||
|
|
||||||
use Symfony\Component\Validator\Constraints;
|
use Symfony\Component\Validator\Constraints;
|
||||||
use Thelia\Model\ConfigQuery;
|
|
||||||
use Symfony\Component\Validator\ExecutionContextInterface;
|
|
||||||
use Thelia\Log\Tlog;
|
|
||||||
use Thelia\Core\Translation\Translator;
|
use Thelia\Core\Translation\Translator;
|
||||||
|
|
||||||
class ConfigStoreForm extends BaseForm
|
class ConfigStoreForm extends BaseForm
|
||||||
@@ -34,12 +31,19 @@ class ConfigStoreForm extends BaseForm
|
|||||||
{
|
{
|
||||||
$this->formBuilder
|
$this->formBuilder
|
||||||
->add("store_name", "text", array(
|
->add("store_name", "text", array(
|
||||||
|
"constraints" => array(
|
||||||
|
new Constraints\NotBlank()
|
||||||
|
),
|
||||||
"label" => Translator::getInstance()->trans('Store name'),
|
"label" => Translator::getInstance()->trans('Store name'),
|
||||||
"label_attr" => array(
|
"label_attr" => array(
|
||||||
"for" => "store_name"
|
"for" => "store_name"
|
||||||
)
|
)
|
||||||
))
|
))
|
||||||
->add("store_email", "text", array(
|
->add("store_email", "text", array(
|
||||||
|
"constraints" => array(
|
||||||
|
new Constraints\NotBlank(),
|
||||||
|
new Constraints\Email()
|
||||||
|
),
|
||||||
"label" => Translator::getInstance()->trans('Store email address'),
|
"label" => Translator::getInstance()->trans('Store email address'),
|
||||||
"label_attr" => array(
|
"label_attr" => array(
|
||||||
"for" => "store_email"
|
"for" => "store_email"
|
||||||
@@ -49,40 +53,45 @@ class ConfigStoreForm extends BaseForm
|
|||||||
"label" => Translator::getInstance()->trans('Business ID'),
|
"label" => Translator::getInstance()->trans('Business ID'),
|
||||||
"label_attr" => array(
|
"label_attr" => array(
|
||||||
"for" => "store_business_id"
|
"for" => "store_business_id"
|
||||||
)
|
),
|
||||||
|
"required" => false
|
||||||
))
|
))
|
||||||
->add("store_phone", "text", array(
|
->add("store_phone", "text", array(
|
||||||
"label" => Translator::getInstance()->trans("Phone"),
|
"label" => Translator::getInstance()->trans("Phone"),
|
||||||
"label_attr" => array(
|
"label_attr" => array(
|
||||||
"for" => "store_phone"
|
"for" => "store_phone"
|
||||||
)
|
),
|
||||||
|
"required" => false
|
||||||
))
|
))
|
||||||
->add("store_fax", "text", array(
|
->add("store_fax", "text", array(
|
||||||
"label" => Translator::getInstance()->trans("Fax"),
|
"label" => Translator::getInstance()->trans("Fax"),
|
||||||
"label_attr" => array(
|
"label_attr" => array(
|
||||||
"for" => "store_fax"
|
"for" => "store_fax"
|
||||||
)
|
),
|
||||||
|
"required" => false
|
||||||
))
|
))
|
||||||
->add("store_address1", "text", array(
|
->add("store_address1", "text", array(
|
||||||
"constraints" => array(
|
"constraints" => array(
|
||||||
new Constraints\NotBlank()
|
new Constraints\NotBlank()
|
||||||
),
|
),
|
||||||
|
"label" => Translator::getInstance()->trans("Street Address"),
|
||||||
"label_attr" => array(
|
"label_attr" => array(
|
||||||
"for" => "store_address1"
|
"for" => "store_address1"
|
||||||
),
|
)
|
||||||
"label" => Translator::getInstance()->trans("Street Address ")
|
|
||||||
))
|
))
|
||||||
->add("store_address2", "text", array(
|
->add("store_address2", "text", array(
|
||||||
"label" => Translator::getInstance()->trans("Address Line 2"),
|
"label" => Translator::getInstance()->trans("Address Line 2"),
|
||||||
"label_attr" => array(
|
"label_attr" => array(
|
||||||
"for" => "store_address2"
|
"for" => "store_address2"
|
||||||
)
|
),
|
||||||
|
"required" => false
|
||||||
))
|
))
|
||||||
->add("store_address3", "text", array(
|
->add("store_address3", "text", array(
|
||||||
"label" => Translator::getInstance()->trans("Address Line 3"),
|
"label" => Translator::getInstance()->trans("Address Line 3"),
|
||||||
"label_attr" => array(
|
"label_attr" => array(
|
||||||
"for" => "store_address3"
|
"for" => "store_address3"
|
||||||
)
|
),
|
||||||
|
"required" => false
|
||||||
))
|
))
|
||||||
->add("store_zipcode", "text", array(
|
->add("store_zipcode", "text", array(
|
||||||
"constraints" => array(
|
"constraints" => array(
|
||||||
|
|||||||
@@ -50,50 +50,50 @@
|
|||||||
<fieldset>
|
<fieldset>
|
||||||
{form_field form=$form field='store_name'}
|
{form_field form=$form field='store_name'}
|
||||||
<div class="form-group {if $error}has-error{/if}">
|
<div class="form-group {if $error}has-error{/if}">
|
||||||
<label for="{$label_attr.for}" class="control-label">{$label}: </label>
|
<label for="{$label_attr.for}" class="control-label">{$label}:{if $required} <span class="required">*</span>{/if}</label>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{$label}" placeholder="{intl l='Used in your store front'}">
|
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}"{if $required} aria-required="true" required{/if} title="{$label}" placeholder="{intl l='Used in your store front'}">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/form_field}
|
{/form_field}
|
||||||
|
|
||||||
{form_field form=$form field='store_business_id'}
|
{form_field form=$form field='store_business_id'}
|
||||||
<div class="form-group {if $error}has-error{/if}">
|
<div class="form-group {if $error}has-error{/if}">
|
||||||
<label for="{$label_attr.for}" class="control-label">{$label}: </label>
|
<label for="{$label_attr.for}" class="control-label">{$label}:{if $required} <span class="required">*</span>{/if}</label>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{$label}" placeholder="{intl l='Store Business Identification Number (SIRET, etc).'}">
|
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}"{if $required} aria-required="true" required{/if} title="{$label}" placeholder="{intl l='Store Business Identification Number (SIRET, etc).'}">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/form_field}
|
{/form_field}
|
||||||
|
|
||||||
{form_field form=$form field='store_email'}
|
{form_field form=$form field='store_email'}
|
||||||
<div class="form-group {if $error}has-error{/if}">
|
<div class="form-group {if $error}has-error{/if}">
|
||||||
<label for="{$label_attr.for}" class="control-label">{$label}: </label>
|
<label for="{$label_attr.for}" class="control-label">{$label}:{if $required} <span class="required">*</span>{/if}</label>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{$label}" placeholder="{intl l='Email used when you send an email to your customers (Order confirmations, etc).'}">
|
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}"{if $required} aria-required="true" required{/if} title="{$label}" placeholder="{intl l='Email used when you send an email to your customers (Order confirmations, etc).'}">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/form_field}
|
{/form_field}
|
||||||
|
|
||||||
{form_field form=$form field='store_phone'}
|
{form_field form=$form field='store_phone'}
|
||||||
<div class="form-group {if $error}has-error{/if}">
|
<div class="form-group {if $error}has-error{/if}">
|
||||||
<label for="{$label_attr.for}" class="control-label">{$label}: </label>
|
<label for="{$label_attr.for}" class="control-label">{$label}:{if $required} <span class="required">*</span>{/if}</label>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{$label}" placeholder="{intl l=''}">
|
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}"{if $required} aria-required="true" required{/if} title="{$label}" placeholder="{intl l=''}">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/form_field}
|
{/form_field}
|
||||||
|
|
||||||
{form_field form=$form field='store_fax'}
|
{form_field form=$form field='store_fax'}
|
||||||
<div class="form-group {if $error}has-error{/if}">
|
<div class="form-group {if $error}has-error{/if}">
|
||||||
<label for="{$label_attr.for}" class="control-label">{$label}: </label>
|
<label for="{$label_attr.for}" class="control-label">{$label}:{if $required} <span class="required">*</span>{/if}</label>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{$label}" placeholder="{intl l=''}">
|
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}"{if $required} aria-required="true" required{/if} title="{$label}" placeholder="{intl l=''}">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/form_field}
|
{/form_field}
|
||||||
@@ -104,41 +104,41 @@
|
|||||||
|
|
||||||
{form_field form=$form field='store_address1'}
|
{form_field form=$form field='store_address1'}
|
||||||
<div style="margin-bottom: 5px" class="form-group {if $error}has-error{/if}">
|
<div style="margin-bottom: 5px" class="form-group {if $error}has-error{/if}">
|
||||||
<label for="{$label_attr.for}" class="control-label">{$label}{if $required} <span class="required">*</span>{/if} : </label>
|
<label for="{$label_attr.for}" class="control-label">{$label}:{if $required} <span class="required">*</span>{/if}</label>
|
||||||
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{$label}" placeholder="{intl l='Address'}">
|
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}"{if $required} aria-required="true" required{/if} title="{$label}" placeholder="{intl l='Address'}">
|
||||||
</div>
|
</div>
|
||||||
{/form_field}
|
{/form_field}
|
||||||
|
|
||||||
{form_field form=$form field='store_address2'}
|
{form_field form=$form field='store_address2'}
|
||||||
<div style="margin-bottom: 5px" class="form-group">
|
<div style="margin-bottom: 5px" class="form-group">
|
||||||
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{$label}" placeholder="{intl l='Additional address'}">
|
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}"{if $required} aria-required="true" required{/if} title="{$label}" placeholder="{intl l='Additional address'}">
|
||||||
</div>
|
</div>
|
||||||
{/form_field}
|
{/form_field}
|
||||||
|
|
||||||
{form_field form=$form field='store_address3'}
|
{form_field form=$form field='store_address3'}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{$label}" placeholder="{intl l='Additional address'}">
|
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}"{if $required} aria-required="true" required{/if} title="{$label}" placeholder="{intl l='Additional address'}">
|
||||||
</div>
|
</div>
|
||||||
{/form_field}
|
{/form_field}
|
||||||
|
|
||||||
{form_field form=$form field='store_zipcode'}
|
{form_field form=$form field='store_zipcode'}
|
||||||
<div class="form-group {if $error}has-error{/if}">
|
<div class="form-group {if $error}has-error{/if}">
|
||||||
<label for="{$label_attr.for}" class="control-label">{$label}{if $required} <span class="required">*</span>{/if} : </label>
|
<label for="{$label_attr.for}" class="control-label">{$label}:{if $required} <span class="required">*</span>{/if} </label>
|
||||||
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{$label}" placeholder="{intl l='Zip code'}">
|
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}"{if $required} aria-required="true" required{/if} title="{$label}" placeholder="{intl l='Zip code'}">
|
||||||
</div>
|
</div>
|
||||||
{/form_field}
|
{/form_field}
|
||||||
|
|
||||||
{form_field form=$form field='store_city'}
|
{form_field form=$form field='store_city'}
|
||||||
<div class="form-group {if $error}has-error{/if}">
|
<div class="form-group {if $error}has-error{/if}">
|
||||||
<label for="{$label_attr.for}" class="control-label">{$label}{if $required} <span class="required">*</span>{/if} : </label>
|
<label for="{$label_attr.for}" class="control-label">{$label}:{if $required} <span class="required">*</span>{/if}</label>
|
||||||
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{$label}" placeholder="{intl l='City'}">
|
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}"{if $required} aria-required="true" required{/if} title="{$label}" placeholder="{intl l='City'}">
|
||||||
</div>
|
</div>
|
||||||
{/form_field}
|
{/form_field}
|
||||||
|
|
||||||
{form_field form=$form field='store_country'}
|
{form_field form=$form field='store_country'}
|
||||||
<div class="form-group {if $error}has-error{/if}">
|
<div class="form-group {if $error}has-error{/if}">
|
||||||
<label for="{$label_attr.for}" class="control-label">{$label}{if $required} <span class="required">*</span>{/if} : </label>
|
<label for="{$label_attr.for}" class="control-label">{$label}:{if $required} <span class="required">*</span>{/if}</label>
|
||||||
<select name="{$name}" id="{$label_attr.for}" class="form-control">
|
<select name="{$name}" id="{$label_attr.for}" class="form-control"{if $required} aria-required="true" required{/if}>
|
||||||
{loop type="country" name="country1"}
|
{loop type="country" name="country1"}
|
||||||
<option value="{$ID}" {if {$value} == $ID}selected{/if}>{$TITLE}</option>
|
<option value="{$ID}" {if {$value} == $ID}selected{/if}>{$TITLE}</option>
|
||||||
{/loop}
|
{/loop}
|
||||||
|
|||||||
Reference in New Issue
Block a user