When we created the architecture for category tables, we added a category_translation
table. We will alter this table and add a unique index to avoid duplicates for the same country code and category ID. Execute the following query:
ALTER TABLE `learning_phalcon`.`category_translation` ADD UNIQUE ( `category_translation_category_id` , `category_translation_lang` ) COMMENT '';
We will add a new array to the config/config.php
global configuration file that will hold information about i18n
:
'i18n' => [ 'locales' => [ //ISO 639-1: two-letter codes, one per language 'en' => 'English' ] ]
We will now create the form for the add/edit categories. Create a new file in modules/Core/Forms/
, name it CategoryForm.php
, and write the following code:
<?php namespace App\Core\Forms; use Phalcon\Forms\Form; use Phalcon\Forms\Element\Text; use Phalcon\Forms\Element\Select; use Phalcon\Forms\Element\Submit; use Phalcon\Forms\Element\Hidden; use Phalcon\Validation...