---
title: "Wie bekomme ich das hidden-Field im Model?"
url: "https://www.typo3.net/d/115659-wie-bekomme-ich-das-hidden-field-im-model"
source: "typo3.net"
tags: ["Extensions","Extbase","Frage","TYPO3 6"]
created: "2013-08-06"
last_reply: "2013-08-07"
replies: 4
solved: true
page: 1
pages: 1
lang: "de"
---

# Wie bekomme ich das hidden-Field im Model?

Extensions › Extbase · 4 Antworten · gelöst · gestartet 2013-08-06

## Frage

**Unbekannter Benutzer** · 2013-08-06 · [Beitrag #1](https://www.typo3.net/d/115659-wie-bekomme-ich-das-hidden-field-im-model/1)

Hallo,

ich möchte im Backend ein Modul erzeugen mit welchem ich Elemente (Videos) komfortabel verwalten kann.
Dazu habe ich ein Video-Model erstellt und dies um die Sys_Categories erweitert, da diese zur Sortierung und als "Ordner" verwendet werden sollen.

Wenn ich im BE jetzt die Funktion ->findAll(); auf mein Repository ausführe, bekomme ich nur die Datensätze welche aktiv sind. Ich möchte aber auch die Inaktiven sowie den Status ob hidden = 0 oder 1.

Damit möchte ich den Datensatz aktivieren oder deaktivieren.

Gibt es eine "einfache" Funktion mit der ich ->findAll() dazu bewegen kann, bzw. wie muss ich hier vorgehen?

Vielen Dank für jegliche Hilfe!

## Beste Antwort

**Unbekannter Benutzer** · 2013-08-07 · [Beitrag #5](https://www.typo3.net/d/115659-wie-bekomme-ich-das-hidden-field-im-model/5)

Vielen Dank für deine Hilfe! Das war's!

Ich muss zugeben, auf den letzten Teil hätte ich auch selbst kommen können... #sigh#

Nochmals DANKE!

## Antworten

### [#2](https://www.typo3.net/d/115659-wie-bekomme-ich-das-hidden-field-im-model/2) · sunixzs · 2013-08-06

Hallo kapale,

Das hat was mit den enableFields zu tun. Diese kann man deaktivieren und "manuell nachbauen", aber eben ohne das hidden-Attribut.

```php
function findAllForBackend($pid = 0) {
  $query = $this->createQuery();
  $query->getQuerySettings()->setRespectEnableFields(FALSE);
  $query->getQuerySettings()->setRespectStoragePage(FALSE);

  $enableFieldsAnd = array();
  $enableFieldsAnd[] = $query->equals("pid", $pid); // $_GET['id'] in backend
  $enableFieldsAnd[] = $query->equals("deleted", 0);
  //$enableFieldsAnd[] = andere enableFields wie start_time, end_time usw.

  $query->matching($query->logicalAnd($and));

  return $query->execute();
}
```

LG sun

### [#3](https://www.typo3.net/d/115659-wie-bekomme-ich-das-hidden-field-im-model/3) · Unbekannter Benutzer · 2013-08-06

Hallo sun,

vielen Dank erst mal für deine schnelle Antwort.
Leider bin ich - glaube ich - noch nicht ganz am Ziel.
Ich brauche den Wert des Feldes "hidden" in meinem Model, damit ich z.B. mit einer <f:if> Bedienung den Zustand visible/hidden mit der Lampe darstellen kann.
Leider bekomme ich mit deinem Code dieses Feld nicht... :-/

Das bekomme ich zurück mit einem var_dump und ->toArray()

```php
0 => 
    object(KSS\Videomanager\Domain\Model\Video)[309]
      protected 'title' => string 'Hello World!' (length=12)
      protected 'description' => string 'fasd lfhals d' (length=13)
      protected 'posterImage' => string '' (length=0)
      protected 'sourceFile' => string '' (length=0)
      protected 'videoFormat' => string '' (length=0)
      protected 'runtime' => int 1375816188
      protected 'bytesize' => int 2342323
      protected 'lizenz' => string 'MIT' (length=3)
      protected 'captions' => 
        object(TYPO3\CMS\Extbase\Persistence\ObjectStorage)[336]
          private 'warning' => string 'You should never see this warning. If you do, you probably used PHP array functions like current() on the TYPO3\CMS\Extbase\Persistence\ObjectStorage. To retrieve the first result, you can use the rewind() and current() methods.' (length=228)
          protected 'storage' => 
            array (size=0)
              ...
          protected 'isModified' => boolean false
          protected 'addedObjectsPositions' => 
            array (size=0)
              ...
          protected 'removedObjectsPositions' => 
            array (size=0)
              ...
          protected 'positionCounter' => int 0
      protected 'categories' => 
        object(TYPO3\CMS\Extbase\Persistence\Generic\LazyObjectStorage)[361]
          private 'warning' => string 'You should never see this warning. If you do, you probably used PHP array functions like current() on the TYPO3\CMS\Extbase\Persistence\Generic\LazyObjectStorage. To retrieve the first result, you can use the rewind() and current() methods.' (length=240)
          protected 'dataMapper' => 
            object(TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper)[176]
              ...
          protected 'parentObject' => 
            &object(KSS\Videomanager\Domain\Model\Video)[309]
          protected 'propertyName' => string 'categories' (length=10)
          protected 'fieldValue' => string '0' (length=1)
          protected 'isInitialized' => boolean false
          protected 'storage' => 
            array (size=0)
              ...
          protected 'isModified' => boolean false
          protected 'addedObjectsPositions' => 
            array (size=0)
              ...
          protected 'removedObjectsPositions' => 
            array (size=0)
              ...
          protected 'positionCounter' => int 0
          private 'warning' (TYPO3\CMS\Extbase\Persistence\ObjectStorage) => string 'You should never see this warning. If you do, you probably used PHP array functions like current() on the TYPO3\CMS\Extbase\Persistence\ObjectStorage. To retrieve the first result, you can use the rewind() and current() methods.' (length=228)
      protected 'uid' => int 1
      protected '_localizedUid' => int 1
      protected '_languageUid' => int 0
      protected 'pid' => int 1
      private '_isClone' (TYPO3\CMS\Extbase\DomainObject\AbstractDomainObject) => boolean false
      private '_cleanProperties' (TYPO3\CMS\Extbase\DomainObject\AbstractDomainObject) => 
        array (size=12)
          'title' => string 'Hello World!' (length=12)
          'description' => string 'fasd lfhals d' (length=13)
          'posterImage' => string '' (length=0)
          'sourceFile' => string '' (length=0)
          'videoFormat' => string '' (length=0)
          'runtime' => int 1375816188
          'bytesize' => int 2342323
          'lizenz' => string 'MIT' (length=3)
          'captions' => 
            object(TYPO3\CMS\Extbase\Persistence\ObjectStorage)[334]
              ...
          'categories' => 
            object(TYPO3\CMS\Extbase\Persistence\Generic\LazyObjectStorage)[359]
              ...
          'uid' => int 1
          'pid' => int 1
```

Hast du mir hier noch einen Tipp? Dann wäre alles perfekt!

Herzlichen Dank!

### [#4](https://www.typo3.net/d/115659-wie-bekomme-ich-das-hidden-field-im-model/4) · sunixzs · 2013-08-07

Moin,

meine Methode ist dafür da, auch 'hidden'-Datensätze aus dem Repo zu holen. Vllt. hatte ich da was missverstanden.

Wenn du das Attribut 'hidden' im Model setzen oder holen willst, müsste es eigentlich reichen, eben diese getter und setter zu definieren. Ein Mapping des Attributs 'hidden' im Model zum Datenbankfeld 'hidden' müsste bereits vorhanden sein, da 'hidden' im TCA definiert ist.

```php
// sinngemaess:
class KSS\Videomanager\Domain\Model\Video {
  /**
   * @var boolean
   */
  protected $hidden;

  /**
   * @return boolean $hidden
   */
  public function getHidden() {
    return $this->hidden;
  }

  /**
   * @return boolean $hidden
   */
  public function isHidden() {
    return $this->getHidden();
  }

  /**
   * @param boolean $hidden
   * @return void
   */
  public function setHidden($hidden) {
    $this->hidden = $hidden;
  }
}
```

LG sun

### [#5](https://www.typo3.net/d/115659-wie-bekomme-ich-das-hidden-field-im-model/5) · Unbekannter Benutzer · 2013-08-07 · Beste Antwort

(Text siehe oben unter „Beste Antwort“.)

---

Quelle: „Wie bekomme ich das hidden-Field im Model?“, typo3.net, https://www.typo3.net/d/115659-wie-bekomme-ich-das-hidden-field-im-model
Beiträge von Mitgliedern des Forums. Bitte mit Link auf die Diskussion zitieren.
