/** * @return void * @desc Create DataValidator objects to validate the edit control */ public function CreateValidators() { # Validate existing rows only if 'add' or 'delete' not clicked, # because those buttons should only affect the row those buttons relate to. $i_rows_posted = count($this->a_rows_posted); if (!$this->controlling_editor->IsInternalPostback() and $i_rows_posted) { $i_last_item = $this->a_rows_posted[$i_rows_posted - 1]; foreach ($this->a_rows_posted as $i) { if ($i == $i_last_item and $this->Adding()) { continue; } # ignore last one if it's the new row $this->CreateValidatorsForItem($i); } } # Validate the new row, unless 'delete' was clicked on another row in this control, # because then only the deleted row should be affected, or unless any internal # button in another control was clicked. if (!$this->DeleteClicked() and !$this->IsUnrelatedInternalPostback()) { $this->CreateValidatorsForItem(); } # If saving, and this control doesn't have its minimum number of items, force a validation error $i_total_items = $this->DataObjects()->GetCount(); if ($i_total_items < $this->i_min_items and !$this->controlling_editor->IsInternalPostback()) { $force_invalid = new RequiredFieldValidator('ForceInvalid', 'Please add at least one item in \'' . strtolower($this->table->GetCaption()) . '\''); $force_invalid->SetValidIfNotFound(false); $this->AddValidator($force_invalid); } }