Save all HTML field names in Controller - it is bad or not bad idea?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
0
down vote

favorite
1












I have sample controller InboxController in my Inbox app. I want control with field name from my controller. If I will control with fields name from controller will not be destroyed MVC rules?



<?php

namespace AppHttpControllers;

use AppUser;
use IlluminateHttpRequest;
use IlluminateSupportFacadesValidator;

class InboxController extends Controller
--------------------------------------------------------------------------
*/

/**
* Recipient field name.
*
* @var string
*/

public $recipient = 'recipient';

/**
* Sender field name.
*
* @var string
*/

public $sender = 'sender';

/**
* Subject field name.
*
* @var string
*/



Html code:



<input type='text' name=" $sender ">






share|improve this question



















  • what are we supposed to be reviewing here? the two controller properties? yes, those are very nice. i have no suggestions. if you want to do something with them and you're not sure how, you should try asking on stackoverflow.
    – Occam's Razor
    Jan 9 at 17:15










  • I just wanted to ask if it would be bad if the field names on the HTML form will be defined on the controller @I wrestled a bear once.
    – Otabek
    Jan 10 at 2:52
















up vote
0
down vote

favorite
1












I have sample controller InboxController in my Inbox app. I want control with field name from my controller. If I will control with fields name from controller will not be destroyed MVC rules?



<?php

namespace AppHttpControllers;

use AppUser;
use IlluminateHttpRequest;
use IlluminateSupportFacadesValidator;

class InboxController extends Controller
--------------------------------------------------------------------------
*/

/**
* Recipient field name.
*
* @var string
*/

public $recipient = 'recipient';

/**
* Sender field name.
*
* @var string
*/

public $sender = 'sender';

/**
* Subject field name.
*
* @var string
*/



Html code:



<input type='text' name=" $sender ">






share|improve this question



















  • what are we supposed to be reviewing here? the two controller properties? yes, those are very nice. i have no suggestions. if you want to do something with them and you're not sure how, you should try asking on stackoverflow.
    – Occam's Razor
    Jan 9 at 17:15










  • I just wanted to ask if it would be bad if the field names on the HTML form will be defined on the controller @I wrestled a bear once.
    – Otabek
    Jan 10 at 2:52












up vote
0
down vote

favorite
1









up vote
0
down vote

favorite
1






1





I have sample controller InboxController in my Inbox app. I want control with field name from my controller. If I will control with fields name from controller will not be destroyed MVC rules?



<?php

namespace AppHttpControllers;

use AppUser;
use IlluminateHttpRequest;
use IlluminateSupportFacadesValidator;

class InboxController extends Controller
--------------------------------------------------------------------------
*/

/**
* Recipient field name.
*
* @var string
*/

public $recipient = 'recipient';

/**
* Sender field name.
*
* @var string
*/

public $sender = 'sender';

/**
* Subject field name.
*
* @var string
*/



Html code:



<input type='text' name=" $sender ">






share|improve this question











I have sample controller InboxController in my Inbox app. I want control with field name from my controller. If I will control with fields name from controller will not be destroyed MVC rules?



<?php

namespace AppHttpControllers;

use AppUser;
use IlluminateHttpRequest;
use IlluminateSupportFacadesValidator;

class InboxController extends Controller
--------------------------------------------------------------------------
*/

/**
* Recipient field name.
*
* @var string
*/

public $recipient = 'recipient';

/**
* Sender field name.
*
* @var string
*/

public $sender = 'sender';

/**
* Subject field name.
*
* @var string
*/



Html code:



<input type='text' name=" $sender ">








share|improve this question










share|improve this question




share|improve this question









asked Jan 9 at 6:17









Otabek

169110




169110











  • what are we supposed to be reviewing here? the two controller properties? yes, those are very nice. i have no suggestions. if you want to do something with them and you're not sure how, you should try asking on stackoverflow.
    – Occam's Razor
    Jan 9 at 17:15










  • I just wanted to ask if it would be bad if the field names on the HTML form will be defined on the controller @I wrestled a bear once.
    – Otabek
    Jan 10 at 2:52
















  • what are we supposed to be reviewing here? the two controller properties? yes, those are very nice. i have no suggestions. if you want to do something with them and you're not sure how, you should try asking on stackoverflow.
    – Occam's Razor
    Jan 9 at 17:15










  • I just wanted to ask if it would be bad if the field names on the HTML form will be defined on the controller @I wrestled a bear once.
    – Otabek
    Jan 10 at 2:52















what are we supposed to be reviewing here? the two controller properties? yes, those are very nice. i have no suggestions. if you want to do something with them and you're not sure how, you should try asking on stackoverflow.
– Occam's Razor
Jan 9 at 17:15




what are we supposed to be reviewing here? the two controller properties? yes, those are very nice. i have no suggestions. if you want to do something with them and you're not sure how, you should try asking on stackoverflow.
– Occam's Razor
Jan 9 at 17:15












I just wanted to ask if it would be bad if the field names on the HTML form will be defined on the controller @I wrestled a bear once.
– Otabek
Jan 10 at 2:52




I just wanted to ask if it would be bad if the field names on the HTML form will be defined on the controller @I wrestled a bear once.
– Otabek
Jan 10 at 2:52










1 Answer
1






active

oldest

votes

















up vote
2
down vote



accepted










I recomend you to use Symfony like form builder. There you can create one form and reuse it anywhere.



$form = FormFactory::create(FormType::class, $user)
->add('name', TextType::class)
->add('email', EmailType::class, [
'rules' => 'unique:users,email',
])
->add('save', SubmitType::class, ['label' => 'Save user']);


What is also good is with this form you can also validate your input at the same time.



 $form->handleRequest();



if ($form->isSubmitted() && $form->isValid())
//Your code



Here is link for repository






share|improve this answer





















    Your Answer




    StackExchange.ifUsing("editor", function ()
    return StackExchange.using("mathjaxEditing", function ()
    StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
    StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
    );
    );
    , "mathjax-editing");

    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "196"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );








     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f184633%2fsave-all-html-field-names-in-controller-it-is-bad-or-not-bad-idea%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    2
    down vote



    accepted










    I recomend you to use Symfony like form builder. There you can create one form and reuse it anywhere.



    $form = FormFactory::create(FormType::class, $user)
    ->add('name', TextType::class)
    ->add('email', EmailType::class, [
    'rules' => 'unique:users,email',
    ])
    ->add('save', SubmitType::class, ['label' => 'Save user']);


    What is also good is with this form you can also validate your input at the same time.



     $form->handleRequest();



    if ($form->isSubmitted() && $form->isValid())
    //Your code



    Here is link for repository






    share|improve this answer

























      up vote
      2
      down vote



      accepted










      I recomend you to use Symfony like form builder. There you can create one form and reuse it anywhere.



      $form = FormFactory::create(FormType::class, $user)
      ->add('name', TextType::class)
      ->add('email', EmailType::class, [
      'rules' => 'unique:users,email',
      ])
      ->add('save', SubmitType::class, ['label' => 'Save user']);


      What is also good is with this form you can also validate your input at the same time.



       $form->handleRequest();



      if ($form->isSubmitted() && $form->isValid())
      //Your code



      Here is link for repository






      share|improve this answer























        up vote
        2
        down vote



        accepted







        up vote
        2
        down vote



        accepted






        I recomend you to use Symfony like form builder. There you can create one form and reuse it anywhere.



        $form = FormFactory::create(FormType::class, $user)
        ->add('name', TextType::class)
        ->add('email', EmailType::class, [
        'rules' => 'unique:users,email',
        ])
        ->add('save', SubmitType::class, ['label' => 'Save user']);


        What is also good is with this form you can also validate your input at the same time.



         $form->handleRequest();



        if ($form->isSubmitted() && $form->isValid())
        //Your code



        Here is link for repository






        share|improve this answer













        I recomend you to use Symfony like form builder. There you can create one form and reuse it anywhere.



        $form = FormFactory::create(FormType::class, $user)
        ->add('name', TextType::class)
        ->add('email', EmailType::class, [
        'rules' => 'unique:users,email',
        ])
        ->add('save', SubmitType::class, ['label' => 'Save user']);


        What is also good is with this form you can also validate your input at the same time.



         $form->handleRequest();



        if ($form->isSubmitted() && $form->isValid())
        //Your code



        Here is link for repository







        share|improve this answer













        share|improve this answer



        share|improve this answer











        answered Jan 10 at 7:49









        Ziya Vakhobov

        361




        361






















             

            draft saved


            draft discarded


























             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f184633%2fsave-all-html-field-names-in-controller-it-is-bad-or-not-bad-idea%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            Python Lists

            Aion

            JavaScript Array Iteration Methods