how to show a form in a grid viewunderstanding grid layout in zendHow we should use zend view helper form with validators + filters?Zend_Form:: When should be form created in view and not in controller?Zend Framework layout or view lagzend get posted variables from static form from the view fileCreating a form view in ZendRendering a form with a view helperZend Form - View helper and form decoratorpassing two tableadaptercolletions to viewHow to sort a view easilyunderstanding grid layout in zend

Can't understand how static works exactly

Giving blur shadow to plot

ExactlyOne extension method

Why did modems have speakers?

Are there any English words pronounced with sounds/syllables that aren't part of the spelling?

How to run a substitute command on only a certain part of the line

Xcode 10.3 Installation

Were Moshe's sons Jewish?

Does switching on an old games console without a cartridge damage it?

Would using carbon dioxide as fuel work to reduce the greenhouse effect?

Why did NASA use Imperial units?

What kind of vegetable has pink and white concentric rings?

What is a plausible power source to indefinitely sustain a space station?

Are there any documented cases of extinction of a species of fungus?

How can Kazakhstan perform MITM attacks on all HTTPS traffic?

How can I calculate the cost of Skyss bus tickets

Company requiring me to let them review research from before I was hired

Do I care if the housing market has gone up or down, if I'm moving from one house to another?

Is it possible to access the complete command line including pipes in a bash script?

Why can't a country print its own money to spend it only abroad?

Short story where a flexible reality hardens to an unchanging one

Adding gears to my grandson's 12" bike

How am I supposed to put out fires?

Bounded Torsion, without Mazur’s Theorem



how to show a form in a grid view


understanding grid layout in zendHow we should use zend view helper form with validators + filters?Zend_Form:: When should be form created in view and not in controller?Zend Framework layout or view lagzend get posted variables from static form from the view fileCreating a form view in ZendRendering a form with a view helperZend Form - View helper and form decoratorpassing two tableadaptercolletions to viewHow to sort a view easilyunderstanding grid layout in zend






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








0















I'm trying a bit around with grid views. I show different contents so the user can have something like a dashboard.



Please have a look at the screenshot:



enter image description here



The notizen area should be a search form.



Here part of my controller action:



 $view = new ViewModel();

$wiedervorlageView = new ViewModel(['wvs' => $this->wvTable->fetchAll()]);
$wiedervorlageView->setTemplate('layout/template/wiedervorlage');

$notizenView = new ViewModel(['notizen' => $this->notizenTable->fetchAll()]);
$notizenView->setTemplate('layout/template/notizen');

$geburtstageview = new ViewModel();
$geburtstageview->setTemplate('layout/template/geburtstageview');

$sidebarBlockView = new ViewModel(['aps' => $this->ansprechpartnerTable->getGeburtstage()]);
$sidebarBlockView->setTemplate('layout/template/block');

$geburtstageview->addChild($sidebarBlockView, 'block');

$view->addChild($wiedervorlageView, 'wiedervorlage')
->addChild($notizenView, 'notizen')
->addChild($geburtstageview, 'geburtstage');

return $view;


And here the search viewscript:



<?php
$title = 'Suche';
$this->headTitle($title);
?>
<h1><?= $this->escapeHtml($title) ?></h1>
<?php

$suche= $form->get('suche');
$suche->setAttribute('class', 'form-control');
$suche->setAttribute('placeholder', 'suche');

$suchtyp= $form->get('suchtyp');
$suchtyp->setAttribute('class', 'form-control');
$suchtyp->setAttribute('placeholder', 'suchtyp');


$submit = $form->get('submit');
$submit->setAttribute('class', 'btn btn-primary');

$form->prepare();

echo $this->form()->openTag($form);
?>

<div class="form-group">
<?= $this->formLabel($suche) ?>
<?= $this->formElement($suche) ?>
<?= $this->formElementErrors()->render($suche, ['class' => 'help-block']) ?>
</div>

<div class="form-group">
<?= $this->formLabel($suchtyp) ?>
<?= $this->formElement($suchtyp) ?>
<?= $this->formElementErrors()->render($suchtyp, ['class' => 'help-block']) ?>
</div>

<?php
echo $this->formSubmit($submit);
echo $this->form()->closeTag();


My question is how to change the notizen area so that it works with the form?
I tried different possibilities but I came to the conclusion that I didn't understood the logic in this case.
Any help or explanation appreciated.



Solution:



ok I changed to partials, before I wanted to try with the described concept to see the difference to the partials. I worked before with partials,my challenge here was really only the form, now it is clear hopefully. But either way, the concept with the partials is much more convenient and readable.



So, I changed the viewscripts like suggested, here for completion the one with the form:



<div class="row">
<h2> Suche </h2>
<?php
$suche= $form->get('suche');
$suche->setAttribute('class', 'form-control');
$suche->setAttribute('placeholder', 'suche');

$suchtyp= $form->get('suchtyp');
$suchtyp->setAttribute('class', 'form-control');
$suchtyp->setAttribute('placeholder', 'suchtyp');

$submit = $form->get('submit');
$submit->setAttribute('class', 'btn btn-primary');

$form->prepare();

echo $this->form()->openTag($form);
?>

<div class="form-group">
<?= $this->formRow($suche) ?>
<?= $this->formElementErrors()->render($suche, ['class' => 'help-block']) ?>
<?= $this->formRow($suchtyp) ?>
<?= $this->formElementErrors()->render($suchtyp, ['class' => 'help-block']) ?>

<?php
echo $this->formSubmit($submit);
echo $this->form()->closeTag(); ?>

</div>
</div>


As I posted this I thought I would need to redirect to the controller Action with the search script. Now I copied it to the same controller action. So it works and it is ok for me.
Here part of the changed controller action for anybody who has the same understanding issue:



 $form = new SearchForm(NULL);
$form->get('submit')->setValue('suche');

return new ViewModel([
'wvs' => $this->wvTable->fetchAll(),
'form' => $form,
'aps' => $this->ansprechpartnerTable->getGeburtstage()
]);









share|improve this question






























    0















    I'm trying a bit around with grid views. I show different contents so the user can have something like a dashboard.



    Please have a look at the screenshot:



    enter image description here



    The notizen area should be a search form.



    Here part of my controller action:



     $view = new ViewModel();

    $wiedervorlageView = new ViewModel(['wvs' => $this->wvTable->fetchAll()]);
    $wiedervorlageView->setTemplate('layout/template/wiedervorlage');

    $notizenView = new ViewModel(['notizen' => $this->notizenTable->fetchAll()]);
    $notizenView->setTemplate('layout/template/notizen');

    $geburtstageview = new ViewModel();
    $geburtstageview->setTemplate('layout/template/geburtstageview');

    $sidebarBlockView = new ViewModel(['aps' => $this->ansprechpartnerTable->getGeburtstage()]);
    $sidebarBlockView->setTemplate('layout/template/block');

    $geburtstageview->addChild($sidebarBlockView, 'block');

    $view->addChild($wiedervorlageView, 'wiedervorlage')
    ->addChild($notizenView, 'notizen')
    ->addChild($geburtstageview, 'geburtstage');

    return $view;


    And here the search viewscript:



    <?php
    $title = 'Suche';
    $this->headTitle($title);
    ?>
    <h1><?= $this->escapeHtml($title) ?></h1>
    <?php

    $suche= $form->get('suche');
    $suche->setAttribute('class', 'form-control');
    $suche->setAttribute('placeholder', 'suche');

    $suchtyp= $form->get('suchtyp');
    $suchtyp->setAttribute('class', 'form-control');
    $suchtyp->setAttribute('placeholder', 'suchtyp');


    $submit = $form->get('submit');
    $submit->setAttribute('class', 'btn btn-primary');

    $form->prepare();

    echo $this->form()->openTag($form);
    ?>

    <div class="form-group">
    <?= $this->formLabel($suche) ?>
    <?= $this->formElement($suche) ?>
    <?= $this->formElementErrors()->render($suche, ['class' => 'help-block']) ?>
    </div>

    <div class="form-group">
    <?= $this->formLabel($suchtyp) ?>
    <?= $this->formElement($suchtyp) ?>
    <?= $this->formElementErrors()->render($suchtyp, ['class' => 'help-block']) ?>
    </div>

    <?php
    echo $this->formSubmit($submit);
    echo $this->form()->closeTag();


    My question is how to change the notizen area so that it works with the form?
    I tried different possibilities but I came to the conclusion that I didn't understood the logic in this case.
    Any help or explanation appreciated.



    Solution:



    ok I changed to partials, before I wanted to try with the described concept to see the difference to the partials. I worked before with partials,my challenge here was really only the form, now it is clear hopefully. But either way, the concept with the partials is much more convenient and readable.



    So, I changed the viewscripts like suggested, here for completion the one with the form:



    <div class="row">
    <h2> Suche </h2>
    <?php
    $suche= $form->get('suche');
    $suche->setAttribute('class', 'form-control');
    $suche->setAttribute('placeholder', 'suche');

    $suchtyp= $form->get('suchtyp');
    $suchtyp->setAttribute('class', 'form-control');
    $suchtyp->setAttribute('placeholder', 'suchtyp');

    $submit = $form->get('submit');
    $submit->setAttribute('class', 'btn btn-primary');

    $form->prepare();

    echo $this->form()->openTag($form);
    ?>

    <div class="form-group">
    <?= $this->formRow($suche) ?>
    <?= $this->formElementErrors()->render($suche, ['class' => 'help-block']) ?>
    <?= $this->formRow($suchtyp) ?>
    <?= $this->formElementErrors()->render($suchtyp, ['class' => 'help-block']) ?>

    <?php
    echo $this->formSubmit($submit);
    echo $this->form()->closeTag(); ?>

    </div>
    </div>


    As I posted this I thought I would need to redirect to the controller Action with the search script. Now I copied it to the same controller action. So it works and it is ok for me.
    Here part of the changed controller action for anybody who has the same understanding issue:



     $form = new SearchForm(NULL);
    $form->get('submit')->setValue('suche');

    return new ViewModel([
    'wvs' => $this->wvTable->fetchAll(),
    'form' => $form,
    'aps' => $this->ansprechpartnerTable->getGeburtstage()
    ]);









    share|improve this question


























      0












      0








      0








      I'm trying a bit around with grid views. I show different contents so the user can have something like a dashboard.



      Please have a look at the screenshot:



      enter image description here



      The notizen area should be a search form.



      Here part of my controller action:



       $view = new ViewModel();

      $wiedervorlageView = new ViewModel(['wvs' => $this->wvTable->fetchAll()]);
      $wiedervorlageView->setTemplate('layout/template/wiedervorlage');

      $notizenView = new ViewModel(['notizen' => $this->notizenTable->fetchAll()]);
      $notizenView->setTemplate('layout/template/notizen');

      $geburtstageview = new ViewModel();
      $geburtstageview->setTemplate('layout/template/geburtstageview');

      $sidebarBlockView = new ViewModel(['aps' => $this->ansprechpartnerTable->getGeburtstage()]);
      $sidebarBlockView->setTemplate('layout/template/block');

      $geburtstageview->addChild($sidebarBlockView, 'block');

      $view->addChild($wiedervorlageView, 'wiedervorlage')
      ->addChild($notizenView, 'notizen')
      ->addChild($geburtstageview, 'geburtstage');

      return $view;


      And here the search viewscript:



      <?php
      $title = 'Suche';
      $this->headTitle($title);
      ?>
      <h1><?= $this->escapeHtml($title) ?></h1>
      <?php

      $suche= $form->get('suche');
      $suche->setAttribute('class', 'form-control');
      $suche->setAttribute('placeholder', 'suche');

      $suchtyp= $form->get('suchtyp');
      $suchtyp->setAttribute('class', 'form-control');
      $suchtyp->setAttribute('placeholder', 'suchtyp');


      $submit = $form->get('submit');
      $submit->setAttribute('class', 'btn btn-primary');

      $form->prepare();

      echo $this->form()->openTag($form);
      ?>

      <div class="form-group">
      <?= $this->formLabel($suche) ?>
      <?= $this->formElement($suche) ?>
      <?= $this->formElementErrors()->render($suche, ['class' => 'help-block']) ?>
      </div>

      <div class="form-group">
      <?= $this->formLabel($suchtyp) ?>
      <?= $this->formElement($suchtyp) ?>
      <?= $this->formElementErrors()->render($suchtyp, ['class' => 'help-block']) ?>
      </div>

      <?php
      echo $this->formSubmit($submit);
      echo $this->form()->closeTag();


      My question is how to change the notizen area so that it works with the form?
      I tried different possibilities but I came to the conclusion that I didn't understood the logic in this case.
      Any help or explanation appreciated.



      Solution:



      ok I changed to partials, before I wanted to try with the described concept to see the difference to the partials. I worked before with partials,my challenge here was really only the form, now it is clear hopefully. But either way, the concept with the partials is much more convenient and readable.



      So, I changed the viewscripts like suggested, here for completion the one with the form:



      <div class="row">
      <h2> Suche </h2>
      <?php
      $suche= $form->get('suche');
      $suche->setAttribute('class', 'form-control');
      $suche->setAttribute('placeholder', 'suche');

      $suchtyp= $form->get('suchtyp');
      $suchtyp->setAttribute('class', 'form-control');
      $suchtyp->setAttribute('placeholder', 'suchtyp');

      $submit = $form->get('submit');
      $submit->setAttribute('class', 'btn btn-primary');

      $form->prepare();

      echo $this->form()->openTag($form);
      ?>

      <div class="form-group">
      <?= $this->formRow($suche) ?>
      <?= $this->formElementErrors()->render($suche, ['class' => 'help-block']) ?>
      <?= $this->formRow($suchtyp) ?>
      <?= $this->formElementErrors()->render($suchtyp, ['class' => 'help-block']) ?>

      <?php
      echo $this->formSubmit($submit);
      echo $this->form()->closeTag(); ?>

      </div>
      </div>


      As I posted this I thought I would need to redirect to the controller Action with the search script. Now I copied it to the same controller action. So it works and it is ok for me.
      Here part of the changed controller action for anybody who has the same understanding issue:



       $form = new SearchForm(NULL);
      $form->get('submit')->setValue('suche');

      return new ViewModel([
      'wvs' => $this->wvTable->fetchAll(),
      'form' => $form,
      'aps' => $this->ansprechpartnerTable->getGeburtstage()
      ]);









      share|improve this question
















      I'm trying a bit around with grid views. I show different contents so the user can have something like a dashboard.



      Please have a look at the screenshot:



      enter image description here



      The notizen area should be a search form.



      Here part of my controller action:



       $view = new ViewModel();

      $wiedervorlageView = new ViewModel(['wvs' => $this->wvTable->fetchAll()]);
      $wiedervorlageView->setTemplate('layout/template/wiedervorlage');

      $notizenView = new ViewModel(['notizen' => $this->notizenTable->fetchAll()]);
      $notizenView->setTemplate('layout/template/notizen');

      $geburtstageview = new ViewModel();
      $geburtstageview->setTemplate('layout/template/geburtstageview');

      $sidebarBlockView = new ViewModel(['aps' => $this->ansprechpartnerTable->getGeburtstage()]);
      $sidebarBlockView->setTemplate('layout/template/block');

      $geburtstageview->addChild($sidebarBlockView, 'block');

      $view->addChild($wiedervorlageView, 'wiedervorlage')
      ->addChild($notizenView, 'notizen')
      ->addChild($geburtstageview, 'geburtstage');

      return $view;


      And here the search viewscript:



      <?php
      $title = 'Suche';
      $this->headTitle($title);
      ?>
      <h1><?= $this->escapeHtml($title) ?></h1>
      <?php

      $suche= $form->get('suche');
      $suche->setAttribute('class', 'form-control');
      $suche->setAttribute('placeholder', 'suche');

      $suchtyp= $form->get('suchtyp');
      $suchtyp->setAttribute('class', 'form-control');
      $suchtyp->setAttribute('placeholder', 'suchtyp');


      $submit = $form->get('submit');
      $submit->setAttribute('class', 'btn btn-primary');

      $form->prepare();

      echo $this->form()->openTag($form);
      ?>

      <div class="form-group">
      <?= $this->formLabel($suche) ?>
      <?= $this->formElement($suche) ?>
      <?= $this->formElementErrors()->render($suche, ['class' => 'help-block']) ?>
      </div>

      <div class="form-group">
      <?= $this->formLabel($suchtyp) ?>
      <?= $this->formElement($suchtyp) ?>
      <?= $this->formElementErrors()->render($suchtyp, ['class' => 'help-block']) ?>
      </div>

      <?php
      echo $this->formSubmit($submit);
      echo $this->form()->closeTag();


      My question is how to change the notizen area so that it works with the form?
      I tried different possibilities but I came to the conclusion that I didn't understood the logic in this case.
      Any help or explanation appreciated.



      Solution:



      ok I changed to partials, before I wanted to try with the described concept to see the difference to the partials. I worked before with partials,my challenge here was really only the form, now it is clear hopefully. But either way, the concept with the partials is much more convenient and readable.



      So, I changed the viewscripts like suggested, here for completion the one with the form:



      <div class="row">
      <h2> Suche </h2>
      <?php
      $suche= $form->get('suche');
      $suche->setAttribute('class', 'form-control');
      $suche->setAttribute('placeholder', 'suche');

      $suchtyp= $form->get('suchtyp');
      $suchtyp->setAttribute('class', 'form-control');
      $suchtyp->setAttribute('placeholder', 'suchtyp');

      $submit = $form->get('submit');
      $submit->setAttribute('class', 'btn btn-primary');

      $form->prepare();

      echo $this->form()->openTag($form);
      ?>

      <div class="form-group">
      <?= $this->formRow($suche) ?>
      <?= $this->formElementErrors()->render($suche, ['class' => 'help-block']) ?>
      <?= $this->formRow($suchtyp) ?>
      <?= $this->formElementErrors()->render($suchtyp, ['class' => 'help-block']) ?>

      <?php
      echo $this->formSubmit($submit);
      echo $this->form()->closeTag(); ?>

      </div>
      </div>


      As I posted this I thought I would need to redirect to the controller Action with the search script. Now I copied it to the same controller action. So it works and it is ok for me.
      Here part of the changed controller action for anybody who has the same understanding issue:



       $form = new SearchForm(NULL);
      $form->get('submit')->setValue('suche');

      return new ViewModel([
      'wvs' => $this->wvTable->fetchAll(),
      'form' => $form,
      'aps' => $this->ansprechpartnerTable->getGeburtstage()
      ]);






      zend-framework zend-form zend-framework3 zend-view






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 28 at 12:11







      pia-sophie

















      asked Mar 26 at 14:38









      pia-sophiepia-sophie

      2203 silver badges15 bronze badges




      2203 silver badges15 bronze badges






















          1 Answer
          1






          active

          oldest

          votes


















          2














          You should really learn to create partials. What you're doing now is mixing concerns.



          What you're doing in your controller will give you a giant mess if/when you have to refactor.



          With partials you would do something like this.



          File: notizen-partial.phtml



          <?php
          /** @var array $notizen */
          ?>

          <table>
          <tr>
          <th>datum</th>
          <th>text</th>
          </tr>
          <tr>
          <td><?= $notizen['datum'] ?></td>
          <td><?= $notizen['text'] ?></td>
          </tr>
          </table>


          So, the above expects a variable $notizen, of type array (hinted in the PHP at the top). You could add some validation that the array is actually present, contains the values, etc. but that's up to you.



          Now, register this partial in the configuration of the module, with the following config:



          'view_manager' => [
          'template_map' => [
          'partial/notizen-partial' => __DIR__ . '/../view/partials/notizen-partial.phtml',
          ],
          ],


          Make sure you correct the path for your situation!!!



          Repeat the above for each little "container" of your data handling (wvs, aps, etc.).




          Next, have an Action return the data you need to the View:



          // ... create/get data

          return [
          'wvs' => $this->wvTable->fetchAll(),
          'notizen' => $this->notizenTable->fetchAll(),
          'aps' => $this->ansprechpartnerTable->getGeburtstage(),
          ];


          This goes to "action-view.phtml", or whatever. This file handles the "place data where it needs to be".



          The layout of the view, based on your screenshot, would be something like this (I'm going under the assumption your using Bootstrap 4.*):



          <div class="row">
          <div class="col-12">
          <!-- That top row - full width -->
          <!-- ## notizen here ## -->
          </div>
          </div>

          <div class="row">
          <div class="col-8">
          <!-- second row - two thirds of width -->
          <!-- Wiedervorlagen here -->
          </div>
          <div class="col-4">
          <!-- second row, second column - one thirds of width -->
          <!-- Geburtstage here -->
          </div>
          </div>


          Now, you need to use the additional partials to display the data in the right locations. For example, your 'notizen' data, is now $notizen variable in this view. However, we're not using it in this view, so lets pass it on to the partial we created earlier, like so:



          <?= $this->partial('partial/notizen-partial, ['notizen' => $notizen]) ?>


          A lot happening here:



          • Calling the partial ViewHelper (look in the folder of this file to see other ViewHelpers already available!)

          • Passing it the name of the partial, which we set in the configuration earlier

          • Passing key/value pairs. The keys will be variable names, the values will be their values (you can add as many as you like/need)

          Place this call in your action view, like so:



          <div class="row">
          <div class="col-12">
          <!-- That top row - full width -->
          <?= $this->partial('partial/notizen-partial, ['notizen' => $notizen]) ?>
          </div>
          </div>


          And you're done.




          You now have:



          • Single partials to display collections of data

          • Using ViewHelpers, so you can recycle the same view in different locations throughout your application

          • Separated concerns of your code (kept displaying in phtml template files, kept data collection / handling in Controller, kept logic in Repositories/Models/Entities)


          I've studiously ignored your pasted Form. The principle for that is the same, you could pass the $form in to a partial and have that partial contain the displaying of the form. Creating something re-usable.



          If you'd like to know more about customizing Form ViewHelpers (e.g. FormRow, FormElement, FormNumber, etc.), please see answers I've given others, such as this one.






          share|improve this answer























          • I'm confused, my problem here is really that I don't know how to make the Controlleraction with the form work. I tried a bit with partials, but in this case I wanted to try with this concept. It is more about learning about different methods. What would I do with this building, if I want to have the form in the notizen area? With changing it to partials I either wouldn't know how to implement the form this way.

            – pia-sophie
            Mar 27 at 10:14











          • Put your form displaying code in the notizen-partial.phtml file. Change the call to <?= $this->partial('partial/notizen-partial, ['form' => $form]) ?>. Works pretty much the same (functional code wise) as from a Controller to the View. (see how pass it an array with key / value pairs, as you do in your controller?)

            – rkeet
            Mar 27 at 10:30










          Your Answer






          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: "1"
          ;
          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',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55359834%2fhow-to-show-a-form-in-a-grid-view%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          2














          You should really learn to create partials. What you're doing now is mixing concerns.



          What you're doing in your controller will give you a giant mess if/when you have to refactor.



          With partials you would do something like this.



          File: notizen-partial.phtml



          <?php
          /** @var array $notizen */
          ?>

          <table>
          <tr>
          <th>datum</th>
          <th>text</th>
          </tr>
          <tr>
          <td><?= $notizen['datum'] ?></td>
          <td><?= $notizen['text'] ?></td>
          </tr>
          </table>


          So, the above expects a variable $notizen, of type array (hinted in the PHP at the top). You could add some validation that the array is actually present, contains the values, etc. but that's up to you.



          Now, register this partial in the configuration of the module, with the following config:



          'view_manager' => [
          'template_map' => [
          'partial/notizen-partial' => __DIR__ . '/../view/partials/notizen-partial.phtml',
          ],
          ],


          Make sure you correct the path for your situation!!!



          Repeat the above for each little "container" of your data handling (wvs, aps, etc.).




          Next, have an Action return the data you need to the View:



          // ... create/get data

          return [
          'wvs' => $this->wvTable->fetchAll(),
          'notizen' => $this->notizenTable->fetchAll(),
          'aps' => $this->ansprechpartnerTable->getGeburtstage(),
          ];


          This goes to "action-view.phtml", or whatever. This file handles the "place data where it needs to be".



          The layout of the view, based on your screenshot, would be something like this (I'm going under the assumption your using Bootstrap 4.*):



          <div class="row">
          <div class="col-12">
          <!-- That top row - full width -->
          <!-- ## notizen here ## -->
          </div>
          </div>

          <div class="row">
          <div class="col-8">
          <!-- second row - two thirds of width -->
          <!-- Wiedervorlagen here -->
          </div>
          <div class="col-4">
          <!-- second row, second column - one thirds of width -->
          <!-- Geburtstage here -->
          </div>
          </div>


          Now, you need to use the additional partials to display the data in the right locations. For example, your 'notizen' data, is now $notizen variable in this view. However, we're not using it in this view, so lets pass it on to the partial we created earlier, like so:



          <?= $this->partial('partial/notizen-partial, ['notizen' => $notizen]) ?>


          A lot happening here:



          • Calling the partial ViewHelper (look in the folder of this file to see other ViewHelpers already available!)

          • Passing it the name of the partial, which we set in the configuration earlier

          • Passing key/value pairs. The keys will be variable names, the values will be their values (you can add as many as you like/need)

          Place this call in your action view, like so:



          <div class="row">
          <div class="col-12">
          <!-- That top row - full width -->
          <?= $this->partial('partial/notizen-partial, ['notizen' => $notizen]) ?>
          </div>
          </div>


          And you're done.




          You now have:



          • Single partials to display collections of data

          • Using ViewHelpers, so you can recycle the same view in different locations throughout your application

          • Separated concerns of your code (kept displaying in phtml template files, kept data collection / handling in Controller, kept logic in Repositories/Models/Entities)


          I've studiously ignored your pasted Form. The principle for that is the same, you could pass the $form in to a partial and have that partial contain the displaying of the form. Creating something re-usable.



          If you'd like to know more about customizing Form ViewHelpers (e.g. FormRow, FormElement, FormNumber, etc.), please see answers I've given others, such as this one.






          share|improve this answer























          • I'm confused, my problem here is really that I don't know how to make the Controlleraction with the form work. I tried a bit with partials, but in this case I wanted to try with this concept. It is more about learning about different methods. What would I do with this building, if I want to have the form in the notizen area? With changing it to partials I either wouldn't know how to implement the form this way.

            – pia-sophie
            Mar 27 at 10:14











          • Put your form displaying code in the notizen-partial.phtml file. Change the call to <?= $this->partial('partial/notizen-partial, ['form' => $form]) ?>. Works pretty much the same (functional code wise) as from a Controller to the View. (see how pass it an array with key / value pairs, as you do in your controller?)

            – rkeet
            Mar 27 at 10:30















          2














          You should really learn to create partials. What you're doing now is mixing concerns.



          What you're doing in your controller will give you a giant mess if/when you have to refactor.



          With partials you would do something like this.



          File: notizen-partial.phtml



          <?php
          /** @var array $notizen */
          ?>

          <table>
          <tr>
          <th>datum</th>
          <th>text</th>
          </tr>
          <tr>
          <td><?= $notizen['datum'] ?></td>
          <td><?= $notizen['text'] ?></td>
          </tr>
          </table>


          So, the above expects a variable $notizen, of type array (hinted in the PHP at the top). You could add some validation that the array is actually present, contains the values, etc. but that's up to you.



          Now, register this partial in the configuration of the module, with the following config:



          'view_manager' => [
          'template_map' => [
          'partial/notizen-partial' => __DIR__ . '/../view/partials/notizen-partial.phtml',
          ],
          ],


          Make sure you correct the path for your situation!!!



          Repeat the above for each little "container" of your data handling (wvs, aps, etc.).




          Next, have an Action return the data you need to the View:



          // ... create/get data

          return [
          'wvs' => $this->wvTable->fetchAll(),
          'notizen' => $this->notizenTable->fetchAll(),
          'aps' => $this->ansprechpartnerTable->getGeburtstage(),
          ];


          This goes to "action-view.phtml", or whatever. This file handles the "place data where it needs to be".



          The layout of the view, based on your screenshot, would be something like this (I'm going under the assumption your using Bootstrap 4.*):



          <div class="row">
          <div class="col-12">
          <!-- That top row - full width -->
          <!-- ## notizen here ## -->
          </div>
          </div>

          <div class="row">
          <div class="col-8">
          <!-- second row - two thirds of width -->
          <!-- Wiedervorlagen here -->
          </div>
          <div class="col-4">
          <!-- second row, second column - one thirds of width -->
          <!-- Geburtstage here -->
          </div>
          </div>


          Now, you need to use the additional partials to display the data in the right locations. For example, your 'notizen' data, is now $notizen variable in this view. However, we're not using it in this view, so lets pass it on to the partial we created earlier, like so:



          <?= $this->partial('partial/notizen-partial, ['notizen' => $notizen]) ?>


          A lot happening here:



          • Calling the partial ViewHelper (look in the folder of this file to see other ViewHelpers already available!)

          • Passing it the name of the partial, which we set in the configuration earlier

          • Passing key/value pairs. The keys will be variable names, the values will be their values (you can add as many as you like/need)

          Place this call in your action view, like so:



          <div class="row">
          <div class="col-12">
          <!-- That top row - full width -->
          <?= $this->partial('partial/notizen-partial, ['notizen' => $notizen]) ?>
          </div>
          </div>


          And you're done.




          You now have:



          • Single partials to display collections of data

          • Using ViewHelpers, so you can recycle the same view in different locations throughout your application

          • Separated concerns of your code (kept displaying in phtml template files, kept data collection / handling in Controller, kept logic in Repositories/Models/Entities)


          I've studiously ignored your pasted Form. The principle for that is the same, you could pass the $form in to a partial and have that partial contain the displaying of the form. Creating something re-usable.



          If you'd like to know more about customizing Form ViewHelpers (e.g. FormRow, FormElement, FormNumber, etc.), please see answers I've given others, such as this one.






          share|improve this answer























          • I'm confused, my problem here is really that I don't know how to make the Controlleraction with the form work. I tried a bit with partials, but in this case I wanted to try with this concept. It is more about learning about different methods. What would I do with this building, if I want to have the form in the notizen area? With changing it to partials I either wouldn't know how to implement the form this way.

            – pia-sophie
            Mar 27 at 10:14











          • Put your form displaying code in the notizen-partial.phtml file. Change the call to <?= $this->partial('partial/notizen-partial, ['form' => $form]) ?>. Works pretty much the same (functional code wise) as from a Controller to the View. (see how pass it an array with key / value pairs, as you do in your controller?)

            – rkeet
            Mar 27 at 10:30













          2












          2








          2







          You should really learn to create partials. What you're doing now is mixing concerns.



          What you're doing in your controller will give you a giant mess if/when you have to refactor.



          With partials you would do something like this.



          File: notizen-partial.phtml



          <?php
          /** @var array $notizen */
          ?>

          <table>
          <tr>
          <th>datum</th>
          <th>text</th>
          </tr>
          <tr>
          <td><?= $notizen['datum'] ?></td>
          <td><?= $notizen['text'] ?></td>
          </tr>
          </table>


          So, the above expects a variable $notizen, of type array (hinted in the PHP at the top). You could add some validation that the array is actually present, contains the values, etc. but that's up to you.



          Now, register this partial in the configuration of the module, with the following config:



          'view_manager' => [
          'template_map' => [
          'partial/notizen-partial' => __DIR__ . '/../view/partials/notizen-partial.phtml',
          ],
          ],


          Make sure you correct the path for your situation!!!



          Repeat the above for each little "container" of your data handling (wvs, aps, etc.).




          Next, have an Action return the data you need to the View:



          // ... create/get data

          return [
          'wvs' => $this->wvTable->fetchAll(),
          'notizen' => $this->notizenTable->fetchAll(),
          'aps' => $this->ansprechpartnerTable->getGeburtstage(),
          ];


          This goes to "action-view.phtml", or whatever. This file handles the "place data where it needs to be".



          The layout of the view, based on your screenshot, would be something like this (I'm going under the assumption your using Bootstrap 4.*):



          <div class="row">
          <div class="col-12">
          <!-- That top row - full width -->
          <!-- ## notizen here ## -->
          </div>
          </div>

          <div class="row">
          <div class="col-8">
          <!-- second row - two thirds of width -->
          <!-- Wiedervorlagen here -->
          </div>
          <div class="col-4">
          <!-- second row, second column - one thirds of width -->
          <!-- Geburtstage here -->
          </div>
          </div>


          Now, you need to use the additional partials to display the data in the right locations. For example, your 'notizen' data, is now $notizen variable in this view. However, we're not using it in this view, so lets pass it on to the partial we created earlier, like so:



          <?= $this->partial('partial/notizen-partial, ['notizen' => $notizen]) ?>


          A lot happening here:



          • Calling the partial ViewHelper (look in the folder of this file to see other ViewHelpers already available!)

          • Passing it the name of the partial, which we set in the configuration earlier

          • Passing key/value pairs. The keys will be variable names, the values will be their values (you can add as many as you like/need)

          Place this call in your action view, like so:



          <div class="row">
          <div class="col-12">
          <!-- That top row - full width -->
          <?= $this->partial('partial/notizen-partial, ['notizen' => $notizen]) ?>
          </div>
          </div>


          And you're done.




          You now have:



          • Single partials to display collections of data

          • Using ViewHelpers, so you can recycle the same view in different locations throughout your application

          • Separated concerns of your code (kept displaying in phtml template files, kept data collection / handling in Controller, kept logic in Repositories/Models/Entities)


          I've studiously ignored your pasted Form. The principle for that is the same, you could pass the $form in to a partial and have that partial contain the displaying of the form. Creating something re-usable.



          If you'd like to know more about customizing Form ViewHelpers (e.g. FormRow, FormElement, FormNumber, etc.), please see answers I've given others, such as this one.






          share|improve this answer













          You should really learn to create partials. What you're doing now is mixing concerns.



          What you're doing in your controller will give you a giant mess if/when you have to refactor.



          With partials you would do something like this.



          File: notizen-partial.phtml



          <?php
          /** @var array $notizen */
          ?>

          <table>
          <tr>
          <th>datum</th>
          <th>text</th>
          </tr>
          <tr>
          <td><?= $notizen['datum'] ?></td>
          <td><?= $notizen['text'] ?></td>
          </tr>
          </table>


          So, the above expects a variable $notizen, of type array (hinted in the PHP at the top). You could add some validation that the array is actually present, contains the values, etc. but that's up to you.



          Now, register this partial in the configuration of the module, with the following config:



          'view_manager' => [
          'template_map' => [
          'partial/notizen-partial' => __DIR__ . '/../view/partials/notizen-partial.phtml',
          ],
          ],


          Make sure you correct the path for your situation!!!



          Repeat the above for each little "container" of your data handling (wvs, aps, etc.).




          Next, have an Action return the data you need to the View:



          // ... create/get data

          return [
          'wvs' => $this->wvTable->fetchAll(),
          'notizen' => $this->notizenTable->fetchAll(),
          'aps' => $this->ansprechpartnerTable->getGeburtstage(),
          ];


          This goes to "action-view.phtml", or whatever. This file handles the "place data where it needs to be".



          The layout of the view, based on your screenshot, would be something like this (I'm going under the assumption your using Bootstrap 4.*):



          <div class="row">
          <div class="col-12">
          <!-- That top row - full width -->
          <!-- ## notizen here ## -->
          </div>
          </div>

          <div class="row">
          <div class="col-8">
          <!-- second row - two thirds of width -->
          <!-- Wiedervorlagen here -->
          </div>
          <div class="col-4">
          <!-- second row, second column - one thirds of width -->
          <!-- Geburtstage here -->
          </div>
          </div>


          Now, you need to use the additional partials to display the data in the right locations. For example, your 'notizen' data, is now $notizen variable in this view. However, we're not using it in this view, so lets pass it on to the partial we created earlier, like so:



          <?= $this->partial('partial/notizen-partial, ['notizen' => $notizen]) ?>


          A lot happening here:



          • Calling the partial ViewHelper (look in the folder of this file to see other ViewHelpers already available!)

          • Passing it the name of the partial, which we set in the configuration earlier

          • Passing key/value pairs. The keys will be variable names, the values will be their values (you can add as many as you like/need)

          Place this call in your action view, like so:



          <div class="row">
          <div class="col-12">
          <!-- That top row - full width -->
          <?= $this->partial('partial/notizen-partial, ['notizen' => $notizen]) ?>
          </div>
          </div>


          And you're done.




          You now have:



          • Single partials to display collections of data

          • Using ViewHelpers, so you can recycle the same view in different locations throughout your application

          • Separated concerns of your code (kept displaying in phtml template files, kept data collection / handling in Controller, kept logic in Repositories/Models/Entities)


          I've studiously ignored your pasted Form. The principle for that is the same, you could pass the $form in to a partial and have that partial contain the displaying of the form. Creating something re-usable.



          If you'd like to know more about customizing Form ViewHelpers (e.g. FormRow, FormElement, FormNumber, etc.), please see answers I've given others, such as this one.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 27 at 8:28









          rkeetrkeet

          2,2862 gold badges17 silver badges37 bronze badges




          2,2862 gold badges17 silver badges37 bronze badges












          • I'm confused, my problem here is really that I don't know how to make the Controlleraction with the form work. I tried a bit with partials, but in this case I wanted to try with this concept. It is more about learning about different methods. What would I do with this building, if I want to have the form in the notizen area? With changing it to partials I either wouldn't know how to implement the form this way.

            – pia-sophie
            Mar 27 at 10:14











          • Put your form displaying code in the notizen-partial.phtml file. Change the call to <?= $this->partial('partial/notizen-partial, ['form' => $form]) ?>. Works pretty much the same (functional code wise) as from a Controller to the View. (see how pass it an array with key / value pairs, as you do in your controller?)

            – rkeet
            Mar 27 at 10:30

















          • I'm confused, my problem here is really that I don't know how to make the Controlleraction with the form work. I tried a bit with partials, but in this case I wanted to try with this concept. It is more about learning about different methods. What would I do with this building, if I want to have the form in the notizen area? With changing it to partials I either wouldn't know how to implement the form this way.

            – pia-sophie
            Mar 27 at 10:14











          • Put your form displaying code in the notizen-partial.phtml file. Change the call to <?= $this->partial('partial/notizen-partial, ['form' => $form]) ?>. Works pretty much the same (functional code wise) as from a Controller to the View. (see how pass it an array with key / value pairs, as you do in your controller?)

            – rkeet
            Mar 27 at 10:30
















          I'm confused, my problem here is really that I don't know how to make the Controlleraction with the form work. I tried a bit with partials, but in this case I wanted to try with this concept. It is more about learning about different methods. What would I do with this building, if I want to have the form in the notizen area? With changing it to partials I either wouldn't know how to implement the form this way.

          – pia-sophie
          Mar 27 at 10:14





          I'm confused, my problem here is really that I don't know how to make the Controlleraction with the form work. I tried a bit with partials, but in this case I wanted to try with this concept. It is more about learning about different methods. What would I do with this building, if I want to have the form in the notizen area? With changing it to partials I either wouldn't know how to implement the form this way.

          – pia-sophie
          Mar 27 at 10:14













          Put your form displaying code in the notizen-partial.phtml file. Change the call to <?= $this->partial('partial/notizen-partial, ['form' => $form]) ?>. Works pretty much the same (functional code wise) as from a Controller to the View. (see how pass it an array with key / value pairs, as you do in your controller?)

          – rkeet
          Mar 27 at 10:30





          Put your form displaying code in the notizen-partial.phtml file. Change the call to <?= $this->partial('partial/notizen-partial, ['form' => $form]) ?>. Works pretty much the same (functional code wise) as from a Controller to the View. (see how pass it an array with key / value pairs, as you do in your controller?)

          – rkeet
          Mar 27 at 10:30








          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55359834%2fhow-to-show-a-form-in-a-grid-view%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현