Ticket #145: Some improvements to flourish...
| Reporter: | stefano.verna | Type: | enhancement | Opened: | 1 year ago | Status: | closed |
|---|---|---|---|---|---|---|---|
| Assigned to: | wbond | Priority: | major | Modified: | 2 months ago | Resolution: | fixed |
Hi there.
On the attached patch the following changes (raw code, just for descriptive purposes):
- Add <strong> tags on fValidation error boxes (this is to improve the ability to change the aspect via CSS, could also be <span>)
- fMessaging::check() doesn't allow the use of the * selector!
- Add the fActiveRecord::populateRequest() method to do the inverse operation of fActiveRecord::populate(). It takes all the record values and sets them in fRequest. This is very useful to use within form edits. In this way, if fURL::isPost() then fActiveRecord::populate() the record, and re-fill the form using fRequest. If not, then fill the form with the current record values simply using ::populateRequest(). And the code form remains the same.
- Add the ability to the fValidation to specify custom regexps for some fields. Usage:
$validator->addCustomFields(array( 'birth_day' => '/^[0-9]{1,2}$/', 'birth_year' => '/^[0-9]{4}$/', 'sex' => '/^(male|female)$/', 'city' => '/^[0-9]+$/' ));
That's it. Thanks for your AWESOME work.
Attachments
History
03/03/09 09:43:30 changed by wbond
- status changed from new to assigned.
- description changed.
03/03/09 09:45:59 changed by stefano.verna
03/03/09 09:57:48 changed by wbond
Awesome, thanks for the patch!
I'm not sure how long pastebin entries stay around, so I'm going to also attach a file with the patch.
I'll probably adapt the fValidation custom rules a little so that a custom error message can be added. I'm thinking the syntax would be nicer to have one custom rule added at a time so that the field, regex and message can all be specified as parameters instead of having to use nested arrays. What are your thoughts?
I think wrapping the field names in some sort of HTML is a good call. I'll need to adapt that to all of the ORM validation stuff too.
With the fActiveRecord method, how do you use it? Most of the time I end up populating the record and then using the record to provide the input values. I'm guessing you are pushing the values back into fRequest and then using fRequest to provide the input values?
03/03/09 09:58:53 changed by wbond
- attachment flourish.patch added.
Patch pulled from pastebin
03/03/09 10:11:02 changed by stefano.verna
- The pastebin should last forever :) - I agree on your idea to provide a single rule at a time! Much readable! - For the ActiveRecord?: this is how I write the form fillup:
$user = new User($id); if (isPost) { // this pushes the form fields within $user $user->populate(); } else { // this pulls $user values outside to fill the fRequest $user->populateRequest(); } <form> <input type="text" name="last_name" value="<?= fRequest::get("name") ?>" /> </form>
So that if it's the first time you're seeing the page, the form will be filled with the current $user values. Hope to be clear :)
04/23/09 13:47:19 changed by wbond
I apologize this has been sitting stagnant for so long. The Oracle improvements I've been working on have tied up a little too much of my time.
Also, I need to finish putting together a contributor license agreement (CLA). It is a document that you'll need to sign that basically says you confirm you have the proper rights to license this code as MIT, that you are licensing it as MIT and that you retain the copyright to the code.
If you don't want to, or can't sign such a document, we can file some of these as enhancement requests and I'll implement them.
04/23/09 16:14:14 changed by stefano.verna
I'm obviously willing to sign the CLA :) Let me know when it's ready. In the meantime, thanks for your beautiful work. Really. I enjoy every single minute spent with your framework.
05/08/09 13:55:47 changed by wbond
Yesterday I posted the PDFs for the CLAs. If you wrote the patch independently, I would need an individual one, if you wrote it while employed by someone else, I would need a corporate CLA.
Thanks!
05/08/09 15:02:27 changed by stefano.verna
If I have to be sincere, all this signing thing is kinda slow, I'm pretty sure this will have as a direct effect a decrease of submitted suggestions/patches. Anyway, when I'll be able to print and scan that paper, I'll mail it to you.
05/09/09 23:04:50 changed by wbond
I definitely know what you are saying. Unfortunately this seems as though it is the generally accepted best-practice for open source development. Luckily it only has to be done once.
Sorry for the inconvenience.
06/05/09 07:45:42 changed by wbond
As of r596 I implemented the '*' and array of names support for fMessaging::check().
In r598 I added a method fValidationException::setFieldFormat() that allows customizing how field names look in error messages. Here's an example to add strong tags like you requested:
fValidationException::setFieldFormat('<strong>%s:</strong> ');
05/27/10 01:45:38 changed by wbond
- status changed from assigned to closed.
- resolution set to fixed.
This ticket has finally been completed with the addition of fValidation::addRegexRule() in r833.

Patch to better describe the proposed changes: http://pastebin.com/fe4b9c37