[development] converting a module from Drupal 5 to Drupal 6
Sheryl (Permutations Software)
sheryl at permutations.com
Wed Jan 21 16:27:43 UTC 2009
Stewart Robinson wrote:
> Op means different things in different places, or at least its values do.
> What function does your copied code come from and do you know the value of
op?
It's related to the admin form. In phpfreechat.module there is this
function:
function phpfreechat_settings() {
return system_settings_form(_phpfreechat_settings());
}
The mystery code is in the function _phpfreechat_settings()in
phpfreechat.inc. It's the first three statements.
I can't figure out what $form_values['op'] refers to, or what it means if
the value is not empty, and I can't figure out how to rewrite
form_set_error('op', 'error message') in case of error - I don't see what
the error conditions tested have to do with buttons or any other control in
the admin form.
I have spent hours digging through Drupal docs trying to figure this out -
docs for the Drupal 5 API, docs for the changes between Drupal 5 and Drupal
6. I'm not asking for links to these articles. I have them. I'm asking for
someone to please give me a substantive answer to these two small questions:
(1) What does $form_values['op'] refer to, and what does it mean if the
value is not empty. (And how does Drupal 6 code this.)
(2) How do I rewrite form_set_error('op', 'error message') for Drupal 6 when
it's being set in response to a condition that has nothing at all to do with
controls in the form?
Thanks.
- Sheryl
On 1/21/09, Sheryl (Permutations Software) <sheryl at permutations.com> wrote:
> I'm converting a module from Drupal 5 to Drupal 6, and I'm having a very
> hard time understanding the change in the use of 'op'. I can't figure out
> how I need to change my code. There are these lines.
>
> if (!empty($form_values['op'])) {
> _phpfreechat_clear_cache();
> _phpfreechat_clear_cookies();
> }
> if (!_phpfreechat_check_install()) {
> form_set_error('op', _phpfreechat_not_found());
> }
> if (!_phpfreechat_check_files()) {
> form_set_error('op', t('Unable to create data folders for
> phpfreechat.'));
> }
>
> I took this module over from someone else, so I don't fully understand the
> use of 'op' here to begin with. Not understanding what it's doing makes it
> very hard to rewrite. I've spent the last two hours on the Drupal site
> trying to figure it out and I'm boggled. All I can tell is that 'op' was
the
> default name of buttons in Drupal 5, but I still can't figure out what's
> being tested in these "if" statements or how I need to rewrite them for
> Drupal 6. Any guidance you can give me would be greatly appreciated!
>
> - Sheryl
>
>
More information about the development
mailing list