If we submit the form without any data now, or with data that doesn’t meet our validation
requirements, such as an invalid email, we should get validation error messages rendered under
each field. Any data we do enter should also be preserved in the input field.
Our Application in Zend Framework 2
150
This would make a good place to commit your code to source control.
If you’re just reading, but want to see the code in action, you can checkout the tag
06-creating-customers:
git
clone https
://
github
.
com
/
mrkrstphr
/
cleanphp
-
example
.
git
git checkout
06-
creating
-
customers
Editing Customers Our next step is to implement the editing of existing customers. Since this code is going to be
very similar to our create customers code, we’ll use the same action and modify it slightly to
handle both new and existing Customers.
Let’s first start by refactoring our
newAction()
to be
newOrEditAction()
, and make sure it still
works before continuing. Let’s start with the
CustomersController
:
// module/Application/src/Application/Controller/CustomersController.php // ...