예제 #1
0
 /**
  * Create the Callback validator that will be used to ensure the
  * RowCollectionEditor is valid.  We iterate over all the editors it has,
  * pass data to the editor via isValid() and return an error message if any
  * editor fails.
  *
  * @return Callback
  */
 protected function createCallbackValidator()
 {
     $validator = new Callback();
     $validator->setCallback(function () {
         return $this->rowCollectionEditor->isValid();
     });
     $validator->setMessage("Some errors were found in your {$this->rowCollectionEditor->getPluralTitle()}.\n            Please double-check and try again.", Callback::INVALID_VALUE);
     return $validator;
 }
 /**
  * Default rendering for a table view context.  Expects a count of
  * items to be present in $rowData in the $mapping index.  Renders
  * that count concatenated with the plural title from the
  * RowCollectionEditor.
  *
  * @param RowCollectionEditor $editor
  * @param TableCell $renderer
  * @param array $rowData
  * @param $mapping
  * @return string
  */
 public function renderTableView(RowCollectionEditor $editor, TableCell $renderer, array $rowData, $mapping)
 {
     $count = $rowData[$mapping];
     $view = $renderer->getView();
     if (1 === $count) {
         $title = $editor->getSingularTitle();
     } else {
         $title = $editor->getPluralTitle();
     }
     return sprintf('%d %s', $view->escapeHtml($count), $view->escapeHtml($title));
 }