As discussed on IRC it would be cool if there would be an html element select fieldapi element.

This element would be an select field with a 'custom' option which show's a textfield for additional input.

The process and submit function take over each logic so the user can just one this element and forget the rest.

Views could use it then.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tim.plunkett’s picture

Status: Active » Needs work
FileSize
2.01 KB

First crack at this. Not sure exactly what I'm doing :)

Needs a bunch of work still. But if I'm going about it the right or wrong way, I'd appreciate someone telling me so.

tim.plunkett’s picture

Status: Needs work » Needs review
FileSize
1.12 KB
2.2 KB

Okay, here's a bit more. Also, a patch for views to use this on fields for "Customize field HTML", as a demo.

I couldn't find anything to base this on, so I made up some stuff. Passing on the #dependency and the #default_values may not be the usual way.

tim.plunkett’s picture

Only triggered elements get #submit callbacks. I was looking for #value_callback.

tim.plunkett’s picture

FileSize
3.52 KB

The texted field needed two dependencies.
Still use ctools-1089912-views-3.patch to test it.

dawehner’s picture

Status: Needs review » Needs work
+++ b/includes/elements.incundefined
@@ -0,0 +1,99 @@
+    '#dependency_count' => 2,

Just a short comment, wouldn't it be possible look at the parent dependency_count and add one.

Powered by Dreditor.

merlinofchaos’s picture

+function ctools_element_info() {
+  ctools_include('elements');
+  return ctools_elements_element_info();
+}

Seems like we should use ctools_passthrough() for this (see ctools_menu() or ctools_theme() etc)

It seems like we should just do this as a generic select + custom element. There's LOTS of things we can use this for. For example, Views has a date format selector. Pick short/long/medium/etc and custom.

I'm not sure we need a double dependency?

If the overall element is dependent upon something else, an inner dependency should stay invisible properly. Trying to merge the dependencies can only lead to crying, I think.

tim.plunkett’s picture

Assigned: dawehner » tim.plunkett

Thanks for all the feedback. I meant to look into ctools_passthrough, was just trying to get it to work first.

Generalizing it sounds good to me.