framework-web:symfony:td3

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentes Révision précédente
Prochaine révision
Révision précédente
framework-web:symfony:td3 [2018/02/21 02:46] – [Formulaire de modification] jcheronframework-web:symfony:td3 [2019/08/31 14:21] (Version actuelle) – modification externe 127.0.0.1
Ligne 32: Ligne 32:
 ===== Création du projet, intégration des composants ===== ===== Création du projet, intégration des composants =====
  
-Exécuter le script de création de la base de données :+Exécuter le script de création de la base de données : {{:framework-web:symfony:td3:projects.sql|}}
  
 <sxh bash:gutter:false> <sxh bash:gutter:false>
-mysql -u root < path/to/boards.sql+mysql -u root < path/to/projects.sql
 </sxh> </sxh>
  
Ligne 483: Ligne 483:
  }  }
 </sxh> </sxh>
 +
 +Modifier la route **/tags** pour qu'elle sollicite une vue et puisse intégrer plus facilement des scripts côté client :
 +
 +<sxh php;title:src/Controller/TagsController.php>
 +...
 +    /**
 +     * @Route("/tags", name="tags")
 +     */
 +    public function tags(TagsGui $gui,TagRepository $tagRepo){
 +    $tags=$tagRepo->findAll();
 +    $gui->dataTable($tags);
 +    return $gui->renderView('Tags/index.html.twig');;
 +    }
 +    
 +</sxh>
 +
 +Ajouter la vue **templates/Tags/index.html.twig** : cette vue contient une zone HTML d'id **update-tag** dans laquelle sera affiché le formulaire de modification
 +
 +<sxh html;title:templates/Tags/index.html.twig>
 +<div id="update-tag"></div>
 +{{ q["dtTags"] | raw }}
 +{{ script_foot | raw }}
 +</sxh>
 +
  
 Implémenter la méthode **update** dans **TagRepository** : Implémenter la méthode **update** dans **TagRepository** :
Ligne 516: Ligne 540:
     }     }
 </sxh> </sxh>
 +
 +Améliorer le formulaire de modification des tags :
 +
 +<sxh php;title:src/Services/semantic/TagsGui.php>
 +...
 + public function frm(Tag $tag){
 + $colors=Color::getConstants();
 + $frm=$this->_semantic->dataForm("frm-tag", $tag);
 + $frm->setFields(["id","title","color","submit","cancel"]);
 + $frm->setCaptions(["","Title","Color","Valider","Annuler"]);
 + $frm->fieldAsHidden("id");
 + $frm->fieldAsInput("title",["rules"=>["empty","maxLength[30]"]]);
 + $frm->fieldAsDropDown("color",\array_combine($colors,$colors));
 + $frm->setValidationParams(["on"=>"blur","inline"=>true]);
 + $frm->onSuccess("$('#frm-tag').hide();");
 + $frm->fieldAsSubmit("submit","positive","tag/submit", "#dtTags",["ajax"=>["attr"=>"","jqueryDone"=>"replaceWith"]]);
 + $frm->fieldAsLink("cancel",["class"=>"ui button cancel"]);
 + $this->click(".cancel","$('#frm-tag').hide();");
 + $frm->addSeparatorAfter("color");
 + return $frm;
 + }
 +</sxh>
 +
 +{{:framework-web:symfony:td3:tags-frm-2.png?|Tags form}}
 +
  • framework-web/symfony/td3.1519177590.txt.gz
  • Dernière modification : il y a 6 ans
  • (modification externe)