I have been looking at implementing the input type=number field for all CCK Number Fields for HTML5_Form_Tools.

I ran into this dilemma though and vaguely remember discussing it at Drupal Camp NYC. Do we give users the option to select an extra "Textfield type number" in CCK? Or do we override all type Integer/Float/Decimal form fields in a hook_form_alter ?

Last night I was looking at the arrays that drupal_render uses to render these "number textfields", and it was a little more complicated than just changing the type.

Append CCK or just override anything we see in $form that's type => number?

Comments

jensimmons’s picture

Component: Code » Strategy

I just made mew components for HTML5 Tools. Switching this to "Strategy."

LSU_JBob’s picture

After discussing this I think we're leaning towards the latter.

We want something to happen immediately once the module is turned on. If we only provide the end user with the ability to select the widget when making new fields with CCK, we're in theory telling them that they have to go back to all of their content types and change the widget type.

I'm gonna see if I can find the best way to just override any "number textfield". Not going to change number dropdowns or radios/checks.

bleen’s picture

subscribing

LSU_JBob’s picture

I've set up my D6-17 dummy site on my local server with a bunch of devel generated pages. I've added a required CCK integer field to the content type, and devel has provided values for me. When I edit the node, the integer value appears in an element. I want that type to turn from "text" to "number." The CCK field name is field_page_integer.

In the html5 tools module I've used just a regular hook_form_alter to find out if there are any integer fields on the page.

function html5_tools_form_alter(&$form, &$form_state){
	if($form['#id'] == 'node-form'){
		if(isset($form['#field_info'])){
			foreach($form['#field_info'] as $field){
				if($field['type'] == 'number_integer'){
					echo "there is an INTEGER FIELD ON THE PAGE!!!";
				}
			}
		}
	}
}

From this point on though I'm confused on what to do. I've discovered the integer and it's ID. But the actual element on the page is id="edit-field-page-integer-0-value-wrapper". I would just tell jQuery to look for "edit-"+ field_name + "-0-value-wrapper" but I feel like that would just be a hack and not a real solution to this.

How do I get into the function that renders this element and also be sure I'm changing the right one when I change the type from "text" to "number?" Yargh!

bleen’s picture

LSU_JBob:

We havent made the elements module a dependency of html5_tools yet, but we plan to. That module will handle the HTML form fields

ericduran’s picture

Yea, Also There's still discussions over at #816090: Support HTML5 elements regarding the elements and their names. Right now most of the elements got into the elements module but there's still issues regarding the names and problems with other modules that use the same names for elements.

Sadly we can't really start changing fields into the issue is resolve.

LSU_JBob’s picture

Just saw a presentation by ericduran and this seems to be in the module now! Nice!

ericduran’s picture

Yeah, sorry about that. This was fixed in this patch. http://drupal.org/cvs?commit=408228

ericduran’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.