Is this safe, question on validation.

I need to pass an additional var into my custom validation function, I came up with something like this:

$form['title'] = array(
  '#type' => 'textfield',
  '#title' => t('Subject'),
  '#default_value' => $node->title,
  '#size' => 60,
  '#maxlength' => 128,
  '#required' => TRUE,
  '#element_validate' => array('my_validation_function'),
  '#my_var' => 'var_i_want_passed',
);

It works but it feels DIRTY...

Is this safe or is there a better way?

Custom Entity type using Field API to implement Image field

I am using Drupal 7.12, PHP 5.3.2, on ubuntu 11.4

This is more about me learning how to use entities so I have tried to keep everything simple yet use practical fields. So here is what I got.

Entity shows up fine and everything is working. I have created a custom save function in the controller class which writes everything to the entity table. This works great.

I then use the field api function to create the fields and instances - field_create_field($field) and field_create_instance($instance). This works great and I can see the field in the "Manage Fields" section of my entity.

So to recap, I have an entity showing up great and an image field showing up great.

So now I go to the form and enter in the info (just as I had done before), upload an image using the sweet image field. It uploads, I can see the thumbnail and I have options to upload more.

Now here is where it breaks down. When I hit submit I get this error:

Warning: Attempt to modify property of non-object in _field_invoke() (line 224 of /var/www/drupal_7x/modules/field/field.attach.inc).

The kicker is that everything is saving like it's supposed to be, I just get this error. To save you guys some looking, here is what is on line 224 (well 223, 224, and 225) of field.attach.inc:

<?php
if ($items !== array() || isset($entity->{$field_name}[$langcode])) {

Every time i upload and photo i get error code

Every time i upload a photo it takes on edit screen then when i hit save it gives me a error code

The website encountered an unexpected error. Please try again later.

any idea how to fix this i can edit whole site but cant add photos at all.

Drupal core version conflict

Hi,

I'm using version 7.8 and have gotten notification that a security update for the Drupal core is available. Checking the available updates page shows that, yes, core version 7.8 is currently installed and is recommending update to version 7.12 ?! I've been using Drupal off and on for years and have updated several installs, major releases, etc. (marvelous program, btw, it has always seemed to work as it should); but I've not had an occasion where the recommended update was a lower version number that the version currently installed.

How to attach Drupal Behaviors only to specific pages or divs?

Hi,

I have an issue where I get a JS error 'settings is undefined' on pages other than the page where I have a module that calls a javascript file that utilises Drupal attach behaviors.

I only want to call that script on particular pages.

e.g.

$params=array() of the drupal_mail

What do i have to put in the $params=array() of the drupal_mail function when i call it so that i can use the commerce_product tokens?

The drupal_mail function is called from newsletter module

Pages

Subscribe with RSS Subscribe to RSS - Drupal 7.x