PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, February 9, 2022

[FIXED] get value attribute of hidden input field in symfony controller

 February 09, 2022     php, symfony, twig     No comments   

Issue

I'm using Symfony 5 and php7.

{{ form_widget(form.groupTab) }}<input type="hidden" id="ce-participants__type" data-field="app_registration_group_type_form[groupTab]" value="0">

I want to get the value attribute within the hidden input field. It should return '0' as string.

In my controller I`ve tried following:

$groupTab = $form->get('groupTab')->getViewData();

but I always get an empty string as response => ''


Solution

First, your hidden field has no name attribute, so I'm not even sure you can get its value back.

You should create that field with the form builder, just as you do the groupTab field. Then you can get its value with $form->get('yourHiddenField')->getData().



Answered By - Saphir
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home
View mobile version

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing