create shipping zone area form
This commit is contained in:
@@ -130,6 +130,7 @@
|
||||
<form name="thelia.admin.area.country" class="Thelia\Form\Area\AreaCountryForm"/>
|
||||
<form name="thelia.admin.area.postage" class="Thelia\Form\Area\AreaPostageForm"/>
|
||||
|
||||
<form name="thelia.shopping_zone_area" class="Thelia\Form\ShippingZone\ShippingZoneAddArea"/>
|
||||
</forms>
|
||||
|
||||
|
||||
|
||||
87
core/lib/Thelia/Form/ShippingZone/ShippingZoneAddArea.php
Normal file
87
core/lib/Thelia/Form/ShippingZone/ShippingZoneAddArea.php
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Form\ShippingZone;
|
||||
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Symfony\Component\Validator\Constraints\GreaterThan;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Thelia\Form\BaseForm;
|
||||
|
||||
|
||||
/**
|
||||
* Class ShippingZoneAddArea
|
||||
* @package Thelia\Form\ShippingZone
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class ShippingZoneAddArea extends BaseForm
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* in this function you add all the fields you need for your Form.
|
||||
* Form this you have to call add method on $this->formBuilder attribute :
|
||||
*
|
||||
* $this->formBuilder->add("name", "text")
|
||||
* ->add("email", "email", array(
|
||||
* "attr" => array(
|
||||
* "class" => "field"
|
||||
* ),
|
||||
* "label" => "email",
|
||||
* "constraints" => array(
|
||||
* new \Symfony\Component\Validator\Constraints\NotBlank()
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
* ->add('age', 'integer');
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
protected function buildForm()
|
||||
{
|
||||
$this->formBuilder
|
||||
->add('area_id', 'integer', array(
|
||||
'constraints' => array(
|
||||
new NotBlank(),
|
||||
new GreaterThan(array('value' => 0))
|
||||
),
|
||||
'label_attr' => array('for' => 'shipping_area'),
|
||||
'label' => Translator::getInstance()->trans('Area')
|
||||
))
|
||||
->add('shipping_zone_id', 'integer', array(
|
||||
'constraints' => array(
|
||||
new NotBlank(),
|
||||
new GreaterThan(array('value' => 0))
|
||||
)
|
||||
))
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string the name of you form. This name must be unique
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'thelia_shippingzone_area';
|
||||
}
|
||||
}
|
||||
@@ -26,12 +26,22 @@
|
||||
|
||||
<div class="form-container clearfix">
|
||||
<div class="col-md-4">
|
||||
|
||||
{form name="thelia.shopping_zone_area"}
|
||||
<form method="POST" action="">
|
||||
<label class="control-label" for="">{intl l="Zones"}</label>
|
||||
{form_hidden_fields form=$form}
|
||||
|
||||
{form_field form=$form field='success_url'}
|
||||
<input type="hidden" name="{$name}" value="{navigate to="return_to"}" /> {* the url the user is redirected to on login success *}
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='shipping_zone_id'}
|
||||
<input type="hidden" name="{$name}" value="{$shipping_zones_id}" />
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='area_id'}
|
||||
<label class="control-label" for="{$label_attr.for}">{$label}</label>
|
||||
<div class="input-group">
|
||||
<select name="" id="" data-toggle="selectpicker">
|
||||
<select name="{$name}" id="{$label_attr.for}" data-toggle="selectpicker">
|
||||
{loop name="area.module.not_associated" type="area" without_zone=$shipping_zones_id}
|
||||
<option value="{$ID}">{$NAME}</option>
|
||||
{/loop}
|
||||
@@ -40,9 +50,9 @@
|
||||
<button type="submit" class="btn btn-default btn-primary"><span class="glyphicon glyphicon-plus-sign"></span> {intl l="Add"}</button>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{/form_field}
|
||||
</form>
|
||||
|
||||
{/form}
|
||||
</div>
|
||||
|
||||
<div class="col-md-8">
|
||||
|
||||
Reference in New Issue
Block a user