Form generation and validation framework
Posted: Sat Oct 04, 2008 8:00 pm
So I'm playing around with writing a data mapper to use doctrine models with zend form, I'm having an issue with doing hierarchical data. Im trying to represent the depth of a category in a category tree by prefixing it's name space characters ( I used underscores instead of spaces for formatting here )
<option value="6" label="_____Test7" selected="selected">_____Test7</option>
code looks like this
Poblem is zend escapes my input for me, assuming noone would ever use HTML in an input value... I guess this means I'd have issues editing HTML in a textbox with zend form as well? If i just put a ' ' space character the spaces get outputted in the source HTML but the browser ignores them, also I need to be able to have rich form controls with more then just text as values, what form generation tools are the most robust that anyone has experience in?
I'm trying to just get a simple CRUD framework for myself going, where all I have to do is define models, and set a boolean to if the admin should be able to manage categories for that model. What I'm doing now is looking at the metadata of the doctrine active record object, iterating over the fields skipping fields I don't want on the current form ( I have a global list of "blacklisted" fields ).. works for prototype purposes but obviously this thing needs to be more powerful then that.
I was thinking a good solution would be to set up XML files or ini files that specify which fields should be ignored as far as showing them to the user, also some models may have many fields and I may only want a certain set of default fields in the "browse" or "list" screen.
Is there any way with doctrine, or any other tool to do what I'm talking about? Right now my schema looks like
for instance here, when iterating an active record object my application is exposed to the behavior specific fields 'deleted', 'updated_at', etc... which I don't want on my edit form, ideally this would be encapsulated so I wouldn't have to block out these fields manually... the metadata doesn't differentiate between a templated / inherited field or a concreate field
I want to also tell it which fields should be used in certain views, I looked over all documentation for my frameworks several times and searched for an answer as best I could, is there a cleaner way then setting up my own parallel schema files.. I mean if it came down to that I could have my schema files generate the doctrine schema for me, and just define it one place, but that seems a little redundant
All of doctrines code generation stuff is built into their API so you don't have to use physical schema files, I could implement my own schema that has model specific and form specific schema, and passes only the model schema to doctrine.. but it seems like a tool has to already exist for this
Is this an invention or an implementation? Does this exist?
i could just write parallel form schema files and load them into zend_form with zend_config, but that just seems so... tedious
<option value="6" label="_____Test7" selected="selected">_____Test7</option>
code looks like this
Code: Select all
foreach( $tree as $node )
{
$field->addMultiOption( $node['id'], str_repeat( str_repeat(' ', 5 ), $node['level']) . ucwords($node['name']) );
}I'm trying to just get a simple CRUD framework for myself going, where all I have to do is define models, and set a boolean to if the admin should be able to manage categories for that model. What I'm doing now is looking at the metadata of the doctrine active record object, iterating over the fields skipping fields I don't want on the current form ( I have a global list of "blacklisted" fields ).. works for prototype purposes but obviously this thing needs to be more powerful then that.
I was thinking a good solution would be to set up XML files or ini files that specify which fields should be ignored as far as showing them to the user, also some models may have many fields and I may only want a certain set of default fields in the "browse" or "list" screen.
Is there any way with doctrine, or any other tool to do what I'm talking about? Right now my schema looks like
Code: Select all
ContentVideo:
tableName: videos
actAs:
SoftDelete:
Timestampable:
created:
name: created_at
type: timestamp
format: Y-m-d H:i:s
updated:
name: updated_at
type: timestamp
format: Y-m-d H:i:s
columns:
id:
primary: true
autoincrement: true
type: integer(50)
title:
type: string(255)
description:
type: string
I want to also tell it which fields should be used in certain views, I looked over all documentation for my frameworks several times and searched for an answer as best I could, is there a cleaner way then setting up my own parallel schema files.. I mean if it came down to that I could have my schema files generate the doctrine schema for me, and just define it one place, but that seems a little redundant
All of doctrines code generation stuff is built into their API so you don't have to use physical schema files, I could implement my own schema that has model specific and form specific schema, and passes only the model schema to doctrine.. but it seems like a tool has to already exist for this
Is this an invention or an implementation? Does this exist?
i could just write parallel form schema files and load them into zend_form with zend_config, but that just seems so... tedious