Hello all

Please can you assist with two questions:

1. I'm Doctrine 1.2 models with my Agavi app. However I keep getting
error about being unable to find some BaseXXX classes. On debugging
this, I realized that it has something to do with the sequence in
which classes are being loaded. In my models directory, I have classes
like:

Author.php
AuthorTitle.php
BaseAuthor.php
BaseAuthorTitle.php
BaseCollection.php
Collection.php

It seems these files are being loaded in alphabetical order, and so
the first two files are throwing errors as the Base classes that they
extend are not yet loaded. This error does not occur with the
Collection class...I assume because BaseCollection loads first (B) and
then Collection (C) loads, so there is no issue with the inheritance.

I am currently working around the problem by adding the two BaseA...
classes to autoload.xml:

    <autoload 
name="BaseAuthor">%core.lib_dir%/doctrine/BaseAuthor.php</autoload>
    <autoload 
name="BaseAuthorTitle">%core.lib_dir%/doctrine/BaseAuthorTitle.php</autoload>

However this is clearly not a great solution. Can anyone suggest how
to fix this?

2. In a form, I offer the user a choice of authors to link to a book.
The user must select one author and can optionally select more than
one. My form code looks something like this:

    <label for="aid">Author:</label>
    <select id="aid" name="aid[]">
    <?php foreach ($t['authors'] as $a): ?>
    <?php echo "<option value=\"$a[id]\">" . sprintf('%s, %s',
$a['lname'], $a['fname']) . "</option>"; ?>
    <?php endforeach; ?>
    </select>
    <select id="aid" name="aid[]">
    <option value="">--none--</option>
    <?php foreach ($t['authors'] as $a): ?>
    <?php echo "<option value=\"$a[id]\">" . sprintf('%s, %s',
$a['lname'], $a['fname']) . "</option>"; ?>
    <?php endforeach; ?>
    </select>
    <select id="aid" name="aid[]">
    <option value="">--none--</option>
    <?php foreach ($t['authors'] as $a): ?>
    <?php echo "<option value=\"$a[id]\">" . sprintf('%s, %s',
$a['lname'], $a['fname']) . "</option>"; ?>
    <?php endforeach; ?>
    </select>

Can someone suggest how I should validate this? With my current
validation (see below), Agavi throws a validation error unless all
three author fields are mandatorily filled. I need to change this to
throw an error only if none of them are filled, but to accept one or
more values. Current validator is:

      <validator class="number">
        <arguments base="aid[]">
          <argument />
        </arguments>
        <errors>
          <error>ERROR: Author is invalid</error>
        </errors>
        <ae:parameters>
          <ae:parameter name="type">int</ae:parameter>
          <ae:parameter name="required">true</ae:parameter>
          <ae:parameter name="min">1</ae:parameter>
        </ae:parameters>
      </validator>

Thanks for any help,

Vikram

_______________________________________________
users mailing list
[email protected]
http://lists.agavi.org/mailman/listinfo/users

Reply via email to