retrieving values from a fieldset

2 replies [Last post]
rachelglover
Offline
Last seen: 10 years 30 weeks ago
Joined: 2011-11-05

I'm still new to Drupal so this might be a really obvious thing to you all, but it's eluding me so far!

I'm creating a form that has a fieldset like this:

$form['myfieldset'] = array(
    '#title' => 'My field set',
    '#type' => 'fieldset',
);
$form['myfieldset']['item1'] = array(
    '#title' => t('My first fieldset item'),
    '#type' => 'textfield',
);

My question is how to access the value of ['myfieldset']['item1'] once the form is submitted. In my form_submit function, if I try and access the value through
$form_state['values']['item1']
I get an error saying that it doesn't exist. If I try and access it through $form_state['values']['myfieldset']['item1']
it's returned as an array. How do I get access to the value?

dianikol
Offline
Last seen: 7 years 37 weeks ago
Joined: 2011-04-27
$form_state['values']['item1'

$form_state['values']['item1'] should work. can you post the full code?

Did you clear the cache?

rachelglover
Offline
Last seen: 10 years 30 weeks ago
Joined: 2011-11-05
SOLVED

It turns out that the field I'm trying to access is a date field and they're returned as an array of year/month/day.

Add to playlist

Add to , or

Add to new playlist:

Add to playlist
This is a member-only feature
But, it's easy to become a member

Add to cart:


Loading...
Contact us

Below are the supported keyboard shortcuts for our video player.

space
Start / stop video
shift
Go to next video
shift
Go to previous video
Increase or decrease player speed by 20%
Skip ahead or go back by 15 seconds
1...9
Jump to a percentage (2 is 20%, for example)
f
Toggle full screen
Videos Pricing More Search
BuildAModule Logo Icon BuildAModule Logo Icon
Become a member!
$29
1 month
$156
6 months
10% off
$276
12 months
20% off
All memberships come with the following:
24 / 7 access to the entire 1800+ video library
An innovative video player with a rolling transcript
Extensive Drupal and cross-platform training
A thorough and thoughtful training style
Progress tracking
Take notes on specific video sections
Intuitive multi-user management
How many users?
user
Go solo with a single user, or give multiple team members access through one account and get discounts by bundling multiple users into a single membership.