restart thelia form type
This commit is contained in:
@@ -392,6 +392,8 @@ abstract class AbstractCrudController extends BaseAdminController
|
|||||||
// Get the form field values
|
// Get the form field values
|
||||||
$data = $form->getData();
|
$data = $form->getData();
|
||||||
|
|
||||||
|
$dataType = $form->all();
|
||||||
|
|
||||||
$changeEvent = $this->getUpdateEvent($data);
|
$changeEvent = $this->getUpdateEvent($data);
|
||||||
|
|
||||||
$this->dispatch($this->updateEventIdentifier, $changeEvent);
|
$this->dispatch($this->updateEventIdentifier, $changeEvent);
|
||||||
|
|||||||
@@ -76,6 +76,11 @@ class TaxController extends AbstractCrudController
|
|||||||
{
|
{
|
||||||
$event = new TaxEvent();
|
$event = new TaxEvent();
|
||||||
|
|
||||||
|
/* check the requirements */
|
||||||
|
if(!$this->checkRequirements($formData)) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
$event->setLocale($formData['locale']);
|
$event->setLocale($formData['locale']);
|
||||||
$event->setId($formData['id']);
|
$event->setId($formData['id']);
|
||||||
$event->setTitle($formData['title']);
|
$event->setTitle($formData['title']);
|
||||||
@@ -195,4 +200,11 @@ class TaxController extends AbstractCrudController
|
|||||||
"admin.configuration.taxes-rules.list"
|
"admin.configuration.taxes-rules.list"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function checkRequirements($formData)
|
||||||
|
{
|
||||||
|
$type = $formData['type'];
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -12,12 +12,16 @@ class TheliaType extends AbstractType
|
|||||||
{
|
{
|
||||||
$resolver->setDefaults(array(
|
$resolver->setDefaults(array(
|
||||||
'instance' => false,
|
'instance' => false,
|
||||||
'type' => false,
|
'type' => false,
|
||||||
'options' => false,
|
'options' => false,
|
||||||
));
|
));
|
||||||
|
|
||||||
$resolver->setAllowedTypes(array(
|
$resolver->setAllowedTypes(array(
|
||||||
'instance' => array('Thelia\Type\TypeInterface'),
|
'instance' => array('Thelia\Type\TypeInterface'),
|
||||||
|
));
|
||||||
|
|
||||||
|
$resolver->setAllowedValues(array(
|
||||||
|
'type' => array('text', 'choice'),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -151,10 +151,12 @@ class Tax extends BaseI18nLoop
|
|||||||
|
|
||||||
$loopResultRow = new LoopResultRow($loopResult, $tax, $this->versionable, $this->timestampable, $this->countable);
|
$loopResultRow = new LoopResultRow($loopResult, $tax, $this->versionable, $this->timestampable, $this->countable);
|
||||||
|
|
||||||
|
$requirements = json_decode( base64_decode( $tax->getSerializedRequirements() ), true );
|
||||||
|
|
||||||
$loopResultRow
|
$loopResultRow
|
||||||
->set("ID" , $tax->getId())
|
->set("ID" , $tax->getId())
|
||||||
->set("TYPE" , $tax->getType())
|
->set("TYPE" , $tax->getType())
|
||||||
->set("SERIALIZED_REQUIREMENTS" , $tax->getSerializedRequirements())
|
->set("REQUIREMENTS" , $requirements)
|
||||||
->set("IS_TRANSLATED" , $tax->getVirtualColumn('IS_TRANSLATED'))
|
->set("IS_TRANSLATED" , $tax->getVirtualColumn('IS_TRANSLATED'))
|
||||||
->set("LOCALE" , $locale)
|
->set("LOCALE" , $locale)
|
||||||
->set("TITLE" , $tax->getVirtualColumn('i18n_TITLE'))
|
->set("TITLE" , $tax->getVirtualColumn('i18n_TITLE'))
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ namespace Thelia\Form;
|
|||||||
|
|
||||||
use Symfony\Component\Validator\Constraints;
|
use Symfony\Component\Validator\Constraints;
|
||||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||||
|
use Symfony\Component\Validator\ExecutionContextInterface;
|
||||||
use Thelia\Core\Form\Type\TheliaType;
|
use Thelia\Core\Form\Type\TheliaType;
|
||||||
use Thelia\Core\Translation\Translator;
|
use Thelia\Core\Translation\Translator;
|
||||||
use Thelia\TaxEngine\TaxEngine;
|
use Thelia\TaxEngine\TaxEngine;
|
||||||
@@ -54,6 +55,13 @@ class TaxCreationForm extends BaseForm
|
|||||||
"required" => true,
|
"required" => true,
|
||||||
"constraints" => array(
|
"constraints" => array(
|
||||||
new Constraints\NotBlank(),
|
new Constraints\NotBlank(),
|
||||||
|
new Constraints\Callback(
|
||||||
|
array(
|
||||||
|
"methods" => array(
|
||||||
|
array($this, "verifyRequirements"),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
),
|
||||||
),
|
),
|
||||||
"label" => Translator::getInstance()->trans("Type"),
|
"label" => Translator::getInstance()->trans("Type"),
|
||||||
"label_attr" => array("for" => "type_field"),
|
"label_attr" => array("for" => "type_field"),
|
||||||
@@ -66,8 +74,12 @@ class TaxCreationForm extends BaseForm
|
|||||||
->add($type . '_' . $name, new TheliaType(), array(
|
->add($type . '_' . $name, new TheliaType(), array(
|
||||||
"instance" => $requirementType,
|
"instance" => $requirementType,
|
||||||
"constraints" => array(
|
"constraints" => array(
|
||||||
"methods" => array(
|
new Constraints\Callback(
|
||||||
array($this, "verifyTaxId"),
|
array(
|
||||||
|
"methods" => array(
|
||||||
|
array($this, "verifyRequirements"),
|
||||||
|
),
|
||||||
|
)
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
"attr" => array(
|
"attr" => array(
|
||||||
@@ -91,4 +103,11 @@ class TaxCreationForm extends BaseForm
|
|||||||
{
|
{
|
||||||
return "thelia_tax_creation";
|
return "thelia_tax_creation";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function verifyRequirements($value, ExecutionContextInterface $context)
|
||||||
|
{
|
||||||
|
$in = true;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,12 +93,12 @@
|
|||||||
{if $formType == 'choice'}
|
{if $formType == 'choice'}
|
||||||
<select name="{$name}">
|
<select name="{$name}">
|
||||||
{foreach $choices as $choice}
|
{foreach $choices as $choice}
|
||||||
<option value="{$choice->value}">{$choice->label}</option>
|
<option value="{$choice->value}" {if $REQUIREMENTS.$label == $choice->value}selected="selected" {/if}>{$choice->label}</option>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
</select>
|
</select>
|
||||||
{/if}
|
{/if}
|
||||||
{if $formType == 'text'}
|
{if $formType == 'text'}
|
||||||
<input type="text" name="{$name}" value="">
|
<input type="text" name="{$name}" value="{$REQUIREMENTS.$label}">
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{/form_tagged_fields}
|
{/form_tagged_fields}
|
||||||
|
|||||||
Reference in New Issue
Block a user