Japanese text in Symfony form titles -
i'm working on project requires using symfony form component, , need able add kanji of field names. using english works fine:
$form = $this->createformbuilder() ->add('name', texttype::class) ->add('price', texttype::class) ->getform();
when try name of fields in japanese though, error:
fatal error: uncaught exception 'symfony\component\form\exception\invalidargumentexception' message 'the name "名" contains illegal characters. names should start letter, digit or underscore , contain letters, digits, numbers, underscores ("_"), hyphens ("-") , colons (":").
is there way change display name of field?
$form = $this->createformbuilder() ->add('name', texttype::class, [ 'label' => '名', ])->...
this should job, , or use resource file if avoid including language specific characters.
$form = $this->createformbuilder() ->add('name', texttype::class, [ 'label' => form1.name, ])->...
inside translation resource file(e.g. resources/tranlations/labels.ja.yml) add content
form1.name: "名"
Comments
Post a Comment