News Feed
Sections




News Archive
feed this:

Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Hari KT:
Aura Input Form Inside Slim Framework
September 08, 2014 @ 10:55:13

Hari KT has a new post to his site today showing how you can integrate the Aura PHP components into a Slim framework application for input handling, like from a form. Aura PHP is a set of decoupled components for things like CLI handling, dependency injection and SQL requests (among others).

Rob Allen wrote about Integrating ZF2 forms into Slim. I did write how you can use Aura.Input and Aura.Html to create standalone form for PHP. This time I felt I should write about integrating aura input inside Slim.

He includes the Composer configuration to install the HTML and Input components as well as an up-to-date version of the Slim framework. Code showing how to create the form class (a "Contact form") is included, showing both the creation of the elements and the filtering/validation checks put on each. He shows how the Slim routes would handle the request as well as how the view processes the request and displays the form via a helper. You can get the full working code in this repository over on GitHub.

0 comments voice your opinion now!
auraphp framework slim form input html tutorial

Link: http://harikt.com/blog/2014/09/02/aura-input-form-inside-slim-framework/

Rob Allen:
Integrating ZF2 forms into Slim
August 26, 2014 @ 09:40:47

Rob Allen has a helpful post if you've ever wanted to take advantage of the simplicity of the Slim framework and the power of the Zend Framework 2 forms. In this latest post he walks you through the process of setting it all up and using the ZF2 elements outside of the main framework.

Let's say that you want to use Zend Framework 2′s Form component outside of ZF2 itself. In this case, a Slim application. It turns out that Composer makes this quite easy, though there's quite a lot of code involved, so this is a long article. Start with a really simple Slim Application...

His simple Slim application - just one route - handles both the GET and POST actions and uses several ZF2 components besides just the Form (dependencies mostly). He shows you the updates and additions you'll need to make to the service manager configuration and how to set up some custom validation and the form object in the controller. His example form only has two elements, an email field and a submit button and validation is done on the email address when it's submitted. Finally he includes the View object, extended from Slim's that combines some of the ZF2 and Slim handling to correctly render the form.

0 comments voice your opinion now!
form integration slim zendframework2 tutorial validation

Link: http://akrabat.com/zend-framework-2/integrating-zf2-forms-into-slim/

Rob Allen:
Globally overriding validation messages for ZF2 forms
August 19, 2014 @ 10:46:27

Rob Allen has posted a quick hint about overriding validation messages in a Zend Framework v2 based application. This override is related to the output of a standard form and works globally instead of just on a single form.

One thing that I always do when creating a Zend Framework 2 form is override the validation messages for a number of validators - EmailAddress in particular. I recently decided that I should probably sort this one out once and be done with it. Turns out that it's quite easy assuming that you use the FormElementManger to instantiate your forms.

The post includes all the code you'll need to do the override: a custom validator example, the changes you'll need to make to the configuration and an example of a form that uses the custom handling. He explains each of the parts too, showing how they fit together in your module.

0 comments voice your opinion now!
zendframework2 override validation message form tutorial

Link: http://akrabat.com/zend-framework-2/globally-overriding-validation-messages-for-zf2-forms/

NetTuts.com:
Form Validation in Symfony 2
June 12, 2014 @ 10:15:29

NetTuts.com has continued their screencast series introducing the Symfony 2 framework and some of the basic concepts around things like routing, templating and controllers. In this latest post they build on a previous post and show how to use the form validation already built into the framework in some custom forms.

Today we're going to continue where we left off last time, where we learned how to build reusable forms in Symfony 2. In this video, we'll learn how to validate the data that has been submitted to our form to ensure it is in the correct format, meets our data's requirements and then process the form submission accordingly. [Once finished we'll] now have a working form, which validates our data and displays the validation error messages back to the user.

The screencast (also viewable on YouTube) is only about ten minutes long and shows you how to validate a form with an email address and that the other field is "not blank". He does base it off of the form created in the previous tutorial so if you haven't done that one yet, it's better to start there and come back.

0 comments voice your opinion now!
form validation screencast symfony2 tutorial series

Link: http://code.tutsplus.com/tutorials/form-validation-in-symfony-2--cms-21397

SitePoint PHP Blog:
Building and Processing Forms in Symfony 2
June 06, 2014 @ 13:45:07

The SitePoint PHP blog has a new tutorial posted from author Daniel Sipos about form handling in Symfony2. More specifically, about creating them and handling the results from their submission. This is an introduction to the topic and gets into two examples, one focusing on a view implementation and the other using the form builder.

In this tutorial we will look at two examples of using forms in Symfony 2. In the the first, we will place form elements straight in the View file and then handle the form processing manually in the controller. In the second, we'll use the Symfony form system to declare forms in an object oriented way and have Symfony process and persist the values. We will be working on a simple installation of the Symfony framework.As you may know, it comes with a default bundle called AcmeDemoBundle and we will use that to illustrate working with forms.

In the first example he looks at "non-entity forms" and shows how to create the form from normal HTML elements in the view. The form is just a simple input field and a submit button. He includes the code you'll need to process the form submission too. In the second example he includes an example of how to create the same setup but using the Form Builder instead. It's also links it to a data object, making it simpler to save the submission results.

0 comments voice your opinion now!
symfony2 form processing view builder entity manager tutorial

Link: http://www.sitepoint.com/building-processing-forms-in-symfony-2

Master Zend Framework:
Create a Simple File Upload Form in Zend Framework 2
June 04, 2014 @ 11:51:06

On his "Master Zend Framework" site today Matthew Setter has a new tutorial showing you how to create a simple file upload through the forms handling in Zend Framework 2. The form will include three parts: an input filter, a form class and a controller action to request to show the resulting form.

Having trouble getting file uploads integrated into your forms in Zend Framework 2? Or are you just curious about how to do it, and you want a quick rundown? If either of these is you, come walk through today's post with me as I show you a simple example of how it's done - along with how to combine it with filters and validators. Before we get started, I could have composed the code in a much shorter form than have I've composed it. But my assumption is that you're likely using the full-stack framework.

He includes summaries describing each of the three parts of the setup and the code you'll need to create each. The validator checks for things like "too big", "too small" and the correct MIME type on the file given. The form itself only includes the file upload element with a description of "Attachment". The controller action creates the form instance and calls an "isValid" when the upload happens to execute the validation. He also throws in the view template to display the form itself.

0 comments voice your opinion now!
zendframework2 simple file upload tutorial form

Link: http://www.masterzendframework.com/forms-2/simple-file-upload-form

Master Zend Framework:
Howto Handle External Form Element Dependencies with FormElementManager
April 22, 2014 @ 11:58:07

The Master Zend Framework site has posted a tutorial wanting to help you understand external form element dependencies with help from FormElementManager.

Zend Framework 2, like all great PHP frameworks, provides thorough infrastructure for creating forms in your application. Whether that's form objects, form elements, fieldsets, validation groups or that they interact with so many other components in the Zend Framework 2 default libraries. But how do you handle external dependencies? [...] So what if you need a custom form element in your application, one which will render a list of articles from a database table? [...] In today's post, we're going to look at how to create such a custom element, extending the existing select element.

He walks you through the steps you'll need to make the custom element and hook it into the FormElementManager for correct use:

  • Create a New Form Element
  • Implement the getFormElementConfig Method
  • Create a New Form Object
  • Instantiate the Form Via the FormElementManager

Code is included for each step of the way so you can ensure you end up with a working example.

0 comments voice your opinion now!
external form manager element dependencies external tutorial

Link: http://www.masterzendframework.com/zend-form/handle-external-form-element-dependencies-with-formelementmanager

Joshua Thijssen:
Dynamic form modification in Symfony2
March 20, 2014 @ 09:42:16

Joshua Thijssen has a new post to his site looking at a way to dynamically modify forms in a Symfony2-based application. Form handling can be a bit tricky (especially with more complex elements), and modifying them on the fly can be even more difficult.

Sometimes (or actually, a lot of the time), handling forms will go beyond the basics. And even though symfony2 gives you out-of-the-box a really clean way of creating forms, it sometimes just isn't enough. Fortunately, you are not alone in writing forms, and many posts exists with information on how to handle complex forms. In this post, I will try and demonstrate how to create a dynamic form where you can select a city based on the chosen province.

His example lets the user pick their province and then populates the other select with cities in that area. He includes the code for the form to create these two selects and how to pull out the list of provinces to populate the first. He goes through each part of the example code explaining the methods, what they're doing and how a pre-submit event can be used to populate the second list.

0 comments voice your opinion now!
dynamic form value modification symfony2 tutorial

Link: https://www.adayinthelifeof.nl/2014/03/19/dynamic-form-modification-in-symfony2

MaltBlue.com:
Zend Framework 2 - The New HTML5 Form Fields - Part 2
July 12, 2013 @ 13:41:56

Matthew Setter has posted the second part of his look at the HTML5 form support that comes with Zend Framework 2. In this new post, he focuses on a few different fields - month, range, color, week and number.

Owing to the overwhelming popularity of the first post on the new HTML5 fields in Zend Framework 2 here on Malt Blue, it's only right to have a follow up, covering the other available elements. [...] To really show just how effective using these new elements is, each code snippet had an accompanying screenshot of the element, rendered in iOS on iPhone.

He includes examples for each of the element types including a small screenshot and the code needed to create it. They show how to create the elements and define the custom attributes (like the range for a "Number" field or the date range for a "Week").

0 comments voice your opinion now!
zendframework2 form field html5 series introduction

Link: http://www.maltblue.com/php/html5-form-fields-in-zend-framework-2-part-2

MaltBlue.com:
Zend Framework 2 Forms - Simple and Available Everywhere
April 04, 2013 @ 11:29:49

Matt Setter has a new post to his site today about forms in Zend Framework 2 including a full example on how to use them to create a form for user information (first name, last name).

I think it goes without saying, forms are one of the central elements of any web-based application. They're used for everything from logging in, to searching content and managing information. Given that, they should be first-class citizens, able to be developed and reused with relative ease. [...] However, given the amount of options, configurability and flexibility required, this isn't always easy. [...] In today's post, I'm going to assume you have a basic understanding of how forms work now. [...] I'm going to show you how to create flexible, reusable forms in one module and by the power of the ServiceManager reuse them throughout your application.

He starts with the inclusion of a dependency needed for his example - the ZfcUser component (installed via Composer). He then moves on to the actual code for the form creating a reusable module, an entity class for the User and the Fieldset/Form classes for the contents of the form. He also includes the code for the controller action and the view that outputs the form itself and handles the repopulation automagically (and includes a CSRF token).

0 comments voice your opinion now!
zendframework2 form tutorial module zfcuser user

Link: http://www.maltblue.com/zend-framework/simple-zend-framework-2-forms


Community Events





Don't see your event here?
Let us know!


api release series development conference code application community interview laravel version list tips podcast language zendserver developer framework deployment introduction

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework