locked
a form population question RRS feed

  • Question

  • User1034446946 posted

    Hi

    This is a really daft question but I am use to populating a form with an MVC viewModel which has both the value of a drop down list and the values that populated it in the same model.

    in react is it normal to download 2 view models one for the initial values and one to populate the choices? or do i keep them in one?

    I am airing on having two so i don't submit all the population values back to the server, but would appriciated thoughts.

    Sunday, July 5, 2020 12:51 PM

Answers

  • User475983607 posted

    Hi

    This is a really daft question but I am use to populating a form with an MVC viewModel which has both the value of a drop down list and the values that populated it in the same model.

    in react is it normal to download 2 view models one for the initial values and one to populate the choices? or do i keep them in one?

    I am airing on having two so i don't submit all the population values back to the server, but would appriciated thoughts.

    I think you are asking if it is common to have one view model to populate a form and another view model for submitting values.  If so, yes.  That's a very common pattern. 

    If you are asking if it is common for two view models to initialize and populate a select element then NO that's not common or logical IMHO.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, July 5, 2020 1:26 PM
  • User-474980206 posted

    With an spa written react, you don’t have view models. The react app should be calling a formal api, typically written with webapi. Whether to include meta data with data depends. But it is common.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, July 5, 2020 4:07 PM

All replies

  • User475983607 posted

    Hi

    This is a really daft question but I am use to populating a form with an MVC viewModel which has both the value of a drop down list and the values that populated it in the same model.

    in react is it normal to download 2 view models one for the initial values and one to populate the choices? or do i keep them in one?

    I am airing on having two so i don't submit all the population values back to the server, but would appriciated thoughts.

    I think you are asking if it is common to have one view model to populate a form and another view model for submitting values.  If so, yes.  That's a very common pattern. 

    If you are asking if it is common for two view models to initialize and populate a select element then NO that's not common or logical IMHO.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, July 5, 2020 1:26 PM
  • User-474980206 posted

    With an spa written react, you don’t have view models. The react app should be calling a formal api, typically written with webapi. Whether to include meta data with data depends. But it is common.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, July 5, 2020 4:07 PM
  • User1034446946 posted

    thanks

    Monday, July 6, 2020 12:51 PM